Visit Mozilla.org

DOM:window.alert

From MDC

« Gecko DOM Reference

Contents

[edit] Summary

Display an alert dialog with the specified text and an OK button.

[edit] Syntax

window.alert(message);
  • message is a string of text you want to display in the alert dialog.

[edit] Example

window.alert("Hello world!");
// the "window." prefix is optional, so
// alert("Hello world!"); would have the same effect

produces:

Image:AlertHelloWorld.png

[edit] Notes

The alert dialog should be used for messages which do not require any response on the part of the user, other than the acknowledgement of the message.

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.

[edit] Specification

DOM Level 0. Not part of any standard.

[edit] See also

confirm, prompt

For chrome see alert() and alertCheck()