Window confirm() Method - Confirmation box with line-breaks: - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window confirm

Description

Window confirm() Method - Confirmation box with line-breaks:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials