How do I code a pop-up window in JavaScript?

Discussion in 'JavaScript' started by xarzu, Feb 21, 2018.

  1. #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.
     
    xarzu, Feb 21, 2018 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,821
    Likes Received:
    4,539
    Best Answers:
    123
    Trophy Points:
    665
    #2
    if you need anything fancier than this then you'll need html.

    <!DOCTYPE html>
    <html>
    <body>
    
    <p>Click the button to display a confirm box.</p>
    
    <button onclick="myFunction()">Try it</button>
    
    <script>
    function myFunction() {
        confirm("Press a button!");
    }
    </script>
    
    </body>
    </html>
    Code (markup):
     
    sarahk, Feb 21, 2018 IP
    deathshadow likes this.