Conform Dialog Box in JavaScript

 
Confirm Dialog box serves as a technique for confirming user action. In JavaScript Confirm dialog box display these information:

1. A predefined message
2. Ok and Cancel button.

Confirm dialog box requires only ‘a pre-defined message to be displayed’ like this:
confirm(“Message“)

if user click on ‘Ok’ button then dialog box return True to the program, otherwise it returns False.

Example:

<html>
  <head>
    <title>example</title>
  </head>
  <body>
    <script language="javascript">
      var ans=confirm("Do you want to display date on Web page")
      if(ans)
       {
           document.write("You click on 'OK' <h1>Welcome to AuthorCode")
       }
      else
       {
            document.write("you click on 'Cancel'")
       }					 
    </script>
  </body>
</html>