Window confirm() method
Window Object
Definition and Usage
The confirm() method is used to display a dialog box with a specified message and OK and Cancel buttons.
If the visitor clicks "OK", this method returns true, otherwise it returns false.
Syntax
confirm(
message
)
Browser support





All major browsers support the confirm() method
Example
Example
Display a confirmation box reminding the visitor what to click:
function myFunction(){
var x;
var r=confirm("Press a button!");
if (r==true){
x="You pressed the OK button!";
}
else{
x="You pressed the Cancel button!";
}
document.getElementById("demo").innerHTML=x;
}
Try it »
Window Object