Window confirm() Method
Window Object
Definition and Usage
The confirm() method displays a dialog box with a specified message, along
with an OK and a Cancel button.
This method returns true if the visitor clicked "OK", and false otherwise.
Syntax
Browser Support

The confirm() method is supported in all major browsers.
Example
Example
Display a confirm box, and alert what the visitor clicked:
<html>
<head>
<script>
function disp_confirm()
{
var r=confirm("Press a button!")
if (r==true)
{
alert("You pressed OK!")
}
else
{
alert("You pressed Cancel!")
}
}
</script>
</head>
<body>
<input type="button" onclick="disp_confirm()"
value="Display a confirm box">
</body>
</html>
Try it yourself »
Window Object
Thank You For Helping Us!
Your message has been sent to W3Schools.
Close [X]