Javascript examples for Browser Object Model:Window confirm
Window confirm() Method - Display a confirmation box, and output what the user clicked:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww. j a v a 2s . c o m var txt; var r = confirm("Press a button!"); if (r == true) { txt = "You pressed OK!"; } else { txt = "You pressed Cancel!"; } document.getElementById("demo").innerHTML = txt; } </script> </body> </html>