This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

confirm

Summary

Displays a synchronized confirmation dialog box showing the given text and possibly localized OK and Cancel buttons.

Method of dom/Windowdom/Window

Syntax

var confirmed = window.confirm(/* see parameter list */);

Parameters

message

Data-type
String

The message to display in the confirmation dialog box. If no value is provided, the dialog box does not contain a message.

Return Value

Returns an object of type BooleanBoolean

Whether the user confirmed (clicked on OK).

Examples

if(window.confirm('Do you want to contine?')){
// Next action
}else{
// Return to previous
}

Usage

 Not recommended for general use. See the notes for details.

Use this method to let the user confirm some action.

Notes

  • The title bar of the confirmation dialog box cannot be changed.
  • Not recommended due to the following issues -
    • This is a synchronized method call. Meaning, calling this method pauses scripting execution of the window from which this method is called, until the user closes the displayed dialog. Also, depending on your cross tab/window usage, this can sometimes pause scripting executions of other windows/tabs from the same domain.
    • Calling this method in some browsers prevents the user from interacting with the entire browser, or browser window (along with all of its tabs), until the dialog is closed.
    • Intrusive dialog boxes are generally annoying for the user.

Alternatively, create a dialog using other web platform means.

Attributions