View Full Version : JavaScript Pop Up Window Code?

Space Admiral Xarzu
02-22-2018, 03:11 PM
What is the best and easiest way to have a modal window pop up in JavaScript code? I have a function in JavaScript where I would like to put a modal pop up window code in so what I know it is being hit. I did a search engine search on the internet for examples of this but everything I found was accompanied with HTML and CSS code. That is not what I am looking form. Please advise.

02-22-2018, 07:48 PM
This is almost too general of a question, and you will need some HTML and css to have a true modal popup. Perhaps you're talking about an alert or a confirm dialog. These are built in features of javascript and are very bare bones, but the user generally must dismiss them in order to continue. However, many browsers allow these to be disabled. But even a complex modal can be skipped if javascript is turned off or if the user uses the developer tools to delete it.

The alert just gives information (configurable text) and the only option is to click OK to continue. Ex:

alert('Hello World!');

The confirm dialog gives an option to click OK or Cancel. Different things can then happen as a result of the choice made. The text shown to the user is configurable and should suggest the outcome of the choices presented. Ex:

if(confirm('Do you want to continue?')){do something here to continue}else{do something else here to not continue}