Responding to a user clicking "ok" on a confirm alert dialog - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Responding to a user clicking "ok" on a confirm alert dialog

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from   w  w w .  j  ava  2 s .co m
var r = confirm("Press a button!");
if (r == true) {
    console.log("You pressed OK!");
}
else {
    console.log("You pressed Cancel!");
}
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials