Javascript examples for Browser Object Model:Window confirm
Window confirm() Method - Confirmation box with line-breaks:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w.j av a 2s .c o m var txt; var r = confirm("Press a button!\nEither OK or Cancel.\nThe button you pressed will be displayed in the result window."); if (r == true) { txt = "You pressed OK!"; } else { txt = "You pressed Cancel!"; } document.getElementById("demo").innerHTML = txt; } </script> </body> </html>