Section 25.290. Window.alert( ): display a message in a dialog box


25.290. Window.alert( ): display a message in a dialog box

JavaScript 1.0:

25.290.1. Synopsis

 window.alert(message) 

25.290.1.1. Arguments

message

The plain-text (not HTML) string to display in a dialog box popped up over window.

25.290.2. Description

The alert( ) method displays the specified message to the user in a dialog box. The dialog box contains an OK button the user can click to dismiss it. The dialog box is typically modal, and the call to alert( ) typically blocks until the dialog is dismissed.

25.290.3. Usage

Perhaps the most common use of the alert( ) method is to display error messages when the user's input to some form element is invalid in some way. The alert dialog box can inform the user of the problem and explain what needs to be corrected to avoid the problem in the future.

The appearance of the alert( ) dialog box is platform-dependent, but it generally contains graphics that indicate an error, warning, or alert message of some kind. While alert( ) can display any desired message, the alert graphics of the dialog box mean that this method is not appropriate for simple informational messages like "Welcome to my blog" or "You are the 177th visitor this week!"

Note that the message displayed in the dialog box is a string of plain text, not formatted HTML. You can use the newline character "\n" in your strings to break your message across multiple lines. You can also do some rudimentary formatting using spaces and can approximate horizontal rules with underscore characters, but the results depend greatly on the font used in the dialog box and thus are system-dependent.

25.290.4. See Also

Window.confirm( ), Window.prompt( )




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net