How to use Window Object Confirm in JavaScript

In this article I am going to explain about window object Confirm() Method.
  • 1684

JavaScript Window object Confirm() Method

JavaScript confirm() Method use for display confirmation window for user confirmation before any action. Confirmation dialog box return true or false at the behave of user.

Syntax

confirm(Your message)

Example

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            var a;

            var b = confirm("press button");

            if (r == true) {

                x = "Action has been done";

            }

            else {

                x = "Action has not been done";

            }

            document.getElementById("txt").innerHTML = x;

        }

    </script>

</head>

<body>

    <button onclick="myfun()">

        click me</button>

    <p id="txt">

    </p>

</body>

</html>

 

Output

 

confirm.gif


You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2018 DotNetHeaven. All rights reserved.