Section 25.311. Window.prompt( ): get user input with a dialog box


25.311. Window.prompt( ): get user input with a dialog box

JavaScript 1.0:

25.311.1. Synopsis

 window.prompt(message, default) 

25.311.1.1. Arguments

message

The plain-text (not HTML) string to be displayed in the dialog box. It should ask the user to enter the information you want.


default

A string that is displayed as the default input in the dialog box. Pass the empty string ("") to make prompt( ) display an empty input box.

25.311.1.2. Returns

The string entered by the user, the empty string if the user did not enter a string, or null if the user clicked Cancel.

25.311.2. Description

The prompt( ) method displays the specified message in a dialog box that also contains a text input field and OK and Cancel buttons. Platform-dependent graphics in the dialog box help indicate to the user that her input is desired.

If the user clicks the Cancel button, prompt( ) returns null. If the user clicks the OK button, prompt( ) returns the text currently displayed in the input field.

The dialog box that is displayed by the prompt( ) method is modal. That is, it blocks all user input to the main browser window until the user dismisses the dialog box by clicking on the OK or Cancel buttons. Since this method returns a value depending on the user's response to the dialog box, JavaScript execution pauses in the call to prompt( ), and subsequent statements are not executed until the user responds to the dialog box.

25.311.3. See Also

Window.alert( ), Window.confirm( )




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