prompt

You can define the Question and optional the default answer and title

 

String = prompt(Any Question [,Any DefaultAnswer [,String Title]])

 

All Arguments can be any. The method convert all Arguments to String

It return always String.

If User cancel the window, it return empty String

 

 

Examples

 

let sign=window.prompt()
let sign=window.prompt("Are you feeling lucky?");  // messagebox with this text and return the input string
let sign=window.prompt("Are you feeling lucky?","sure"); // same, sure is the default text
let sign=window.prompt("Are you feeling lucky?","sure","the question); // same with title
 

window_prompt

 

Complete Example:

let a=window.prompt("Are you feeling lucky?","sure","the question");
if (a!="") alert(a);
return 1;

 

You can use this without "window" prefix

let sign=prompt("Your Name?")

 

 

 

This method return String

if click on cancel, the object return NULL

 

Notes:

A prompt dialog contains a single-line textbox, a Cancel button, and an OK button, and returns the (possibly empty) text the user entered into that textbox.

 

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).

 

Please note that result is a string. That means you should sometimes cast the value given by the user. For example, if their answer should be a Number, you should cast the value to Number.

 

Server mode

This method return always empty string and don't open the popup window

BeasScript: input