confirm() [FF, IE 3]

Creates a dialog box with two buttons, OK and Cancel, and text specified by the function's parameter. Clicking OK results in the function returning a value of true, and clicking Cancel results in a false value.

Example:

if (confirm("Are you feeling happy?"))
{
    alert("Clap your hands!");
} else {
    alert("Don't worry!");
}

This example calls up a dialog box with the text Are you feeling happy? along with an OK button and a Cancel button. Clicking the OK button causes the function to return true, executing the first part of the if-then-else statement with an alert box showing the words Clap your hands! Clicking Cancel causes the function to return false, triggering the else clause of the if-then-else statement and calling an alert ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.