Javascript Reference
Categories: window

javascript window prompt( )

@March 15, 2008, 1:22 a.m.
prompt( )Firefox/Netscape/NN 2 IE 3 Chrome/Safari/DOM n/a  

prompt("message", "defaultReply")

  

Displays a dialog box with a message, a one-line text entry field, and two clickable buttons. Script execution halts while the dialog box appears. The message should urge the user to enter a specific kind of answer. One button indicates a Cancel operation; the other button indicates the user's approval of the text entered into the field (OK or Yes). The text of the buttons is not scriptable. A click of the Cancel button returns a value of null; a click of the OK button returns a string of whatever is in the text entry field at the time (including the possibility of an empty string). It is up to your scripts to test for the type of response (if any) supplied by the user.

 
Parameters
 
  • Any string.
  • Any string that suggests an answer. Always supply a value, even if an empty string.
 
Returned Value

When clicking the OK button, a string of the text entry field; when clicking Cancel, null.


Powered by Linode.