prompt method (Internet Explorer)

Switch View :
ScriptFree
prompt method

[This documentation is preliminary and is subject to change.]

Displays a dialog box that prompts the user with a message and an input field.

This method is not supported for Metro style apps using JavaScript.

Syntax

var retval = window.prompt(message, defstr);

Standards information

There are no standards that apply here.

Parameters

message [in, optional]

Type: BSTR

String that specifies the message to display in the dialog box. By default, this parameter is set to "".

defstr [in, optional]

Type: BSTR

String that specifies the default value of the input field. By default, this parameter is set to "undefined".

Return value

Type: Variant

String or Integer. Returns the value typed in by the user.

Remarks

The title of this dialog box cannot be changed.

Windows Internet Explorer 7 and later. By default, this method is blocked by the information bar in the Internet zone. This helps prevent malicious sites from initiating spoofing attacks. For more information, please see WebBrowser Customization.

 

 

Build date: 3/8/2012

Community Content

unique_username
Additions
1.) It should also be noted that the prompt dialog in IE only supports 2 lines of text in the prompt message. Any content beyond that is cropped/unreadable.

2.) The dialog also centers on the users desktop - not the browser window, so users with multiple screens will get quite frustrated if the prompt dialog is used frequently.

3.) The styling of the dialog has not been updated since 1995 and thus will not appear to be "directly" related to IE. Its unfortunate that this hasn't been addressed in over 10 years.


Mr. Raymond Kenneth Petry
Proposal - multi-button prompt - extension

Website Designers and Browser Users need more Button Options on their Prompt....

I propose and suggest:

eoPrompt = window.prompt( [sMessage] [, sDefaultValue] [, sButtonName #1] [, sButtonName #2] ...)

Return Value eoPrompt is:
a. vTextData, when no Button is specified (i.e. default "OK/Cancel" Buttons); otherwise--
b. eventObject, when Buttons are specified (i.e. one or more Buttons, plus "Cancel").

Types of prompts:

1. modalprompt() and prompt() are the same, and return values by eoPrompt;

2. modelessprompt(), returns values via the eventObject in the "onprompt" event.

Modelessprompt (and modalprompt secondary-access) returns additional event attributes:

eoPrompt -or- eoPrompt.value = returned value string or integer;

eoPrompt.length = eoPrompt.value.length;

eoPrompt.button = Number of Button-actuated;

eoPrompt.buttonName -or- eoPrompt.button.name = name of Button-actuated;

eoPrompt.actuator = (code) 0=Click, 1=acceleratorKey, 2=enterKey (on tab-selected Button),...

(Plus the usual event attributes, shiftKey, ctrlKey, altKey,... etc.)

(Might also want to know whether null-Return was by empty, Cancel Button, Mouse-X-Off, F4-Key ... and, whether the Value has been changed from it's initial ...)

e.g. Designer might want:

I. A Find dialogBox that allows find-(Prior/Next)-on-page/find-on-site/find-on-web/find-in-dictionary/find-in-thesaurus ... that's six buttons and one string ...
II. A prompt calculator ...

Write.open() is just too slow to get-it-up ... And, show popup is too mouse-shy 'ephemeral'.... We want the 'middle bear' with more buttons ... 21-Questions is a game, not a technology.

COMMENT:

An alternative equivalent might be a fully-floating-frame.


Thomas Lee
Some suggestions for improving this article
1. In the Syntax section, the article says: "vTextData = window...." The variable "vTextData" is never referred to again.
2. In the Return Values section, the article should mention vTextData.
3. In the Return Values section, the article should explain when the return is an integer and when it's a string.
4. In the Remarks section, the article states the title can not be changed. The article should define the title.
5. The article should describe somehow the buttons on the prompt box (which silentdoug's comment above relates to).
6. The contents should show an example of the box

Thomas Lee
Cancel = null
If the user clicks the Cancel button, the return value is null.