How do I code a pop up window in JavaScript?

html-css
js

#1

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.


#2

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


#3

You can learn that from this youtube video


#4

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.


#5

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


#6

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


#7

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


#8

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


#9

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