Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • JavaScript Popup Boxes

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 159
    Comment on it

    Alert Box

    An alert box is used if you want to make sure that user has provided the information .
    user have to click "OK" to proceed whenever pop-up arises.

    Syntax
    window.alert("sometext");
    Example:

    <!DOCTYPE html>
    <html>
    <body>
    
    <p>Click the button for alert box</p>
    
    <button onclick="me()">Try it</button>
    
    <script>
    function me() {
        alert("I am an alert box!");
    }
    </script>
    
    </body>
    </html>
    

    Confirm Box
    A confirm box is used if you user needs to verify something.

    user needs to click either "OK" or "Cancel" to proceed, whenever pop-up box arises

    If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.

    Syntax
    window.confirm("sometext");
    Example:

    <!DOCTYPE html>
    <html>
    <body>
    
    <p>Click the button for a confirm box.</p>
    
    <button onclick="confm()">Try it</button>
    
    <p id="c"></p>
    
    <script>
    function confm() {
        var x;
        if (confirm("Press a button!") == true) {
            x = "user pressed OK!";
        } else {
            x = "user pressed Cancel!";
        }
        document.getElementById("c").innerHTML = x;
    }
    </script>
    
    </body>
    </html>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: