How do I code a pop up window in JavaScript?

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.

I would create the modal pop up window in html and css actually, you can make it in JavaScript, but its tedious work.

simply hide the modal window (with display: none;) until you need it, and then use a click event with javascript to change the display property to block.

The click event can then handle what is inside your JS function, that should work

You can learn that from this youtube video

i found a w3schools example as well, but i am not a fan of w3schools

the only JS involved are getting the elements and adding click events to manipulate css display property, its pretty straight forward really.

Yes, it is but I think it will be good for beginners if I share a link as well.
I don’t have any problem with what you said but I thought that that will be better for @xarzu

true, but i much help the learner with the code they already have. Those tutorials can be found online, so i on purpose didn’t refer to them

1 Like

I am having good luck using an “alert” statement.

yes, alert statement is okay but you will not able to style that pop-up.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.