Latest web development tutorials

Window confirm () method

Window Object Reference Window object

Definition and Usage

confirm () method is used to display a specific message and confirm and cancel button of the dialog with.

If a visitor clicks on "OK", this method returns true, otherwise returns false.

grammar

confirm(message)


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support confirm () method


Examples

Examples

A confirmation box appears, click remind visitors what:

function myFunction () {
var x;
var r = confirm ( "Press the button!");
if (r == true) {
x = "you press \" OK \ "button!";
}
else {
x = "you press the \" Cancel \ "button!";
}
. Document.getElementById ( "demo") innerHTML = x;
}

try it"


Window Object Reference Window object