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.

alert

Summary

Displays a synchronized dialog box showing the given text and a localized OK button.

Method of dom/Windowdom/Window

Syntax

 window.alert(/* see parameter list */);

Parameters

message

Data-type
String

The message to display in the dialog box.

Return Value

No return value

Examples

window.alert('A message from the web page');

Usage

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

Use this method to alert the user with some text.

Notes

  • You cannot change the title bar of the Alert dialog box.
  • 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