Mozilla.com

  1. MDC
  2. Main Page
  3. DOM
  4. window.confirm

« Gecko DOM Reference

Summary

Displays a modal dialog with a message and two buttons, OK and Cancel.

Syntax

result = window.confirm(message);
  • message is the string to be displayed in the dialog.
  • result is a boolean value indicating whether OK or Cancel was selected (true means OK).

Example

if (window.confirm("Want to see my mood ring?")) { 
    window.open("mood.html", "mood ring", "");
}

Notes

Dialog boxes are modal windows - they prevent the user from accessing the rest of the program's interface until the dialog box is closed. For this reason, you should not overuse any function that creates a dialog box (or modal window).

Chrome users (e.g. extensions) should use methods of nsIPromptService instead.

Specification

DOM Level 0. Not part of any standard.

See also

alert, prompt

Languages

Page last modified 17:01, 5 Jan 2008 by Mgjbot

Files (0)