JavaScript About User Prompts


Example

User Prompts are methods part of the Web Application API used to invoke Browser modals requesting a user action such as confirmation or input.

window.alert(message)

Show a modal popup with a message to the user.
Requires the user to click [OK] to dismiss.

alert("Hello World"); 

More information below in "Using alert()".

boolean = window.confirm(message)

Show a modal popup with the provided message.
Provides [OK] and [Cancel] buttons which will respond with a boolean value true / false respectively.

confirm("Delete this comment?");

result = window.prompt(message, defaultValue)

Show a modal popup with the provided message and an input field with an optional pre-filled value.
Returns as result the user provided input value.

prompt("Enter your website address", "http://");

More information below in "Usage of prompt()".


window.print()

Opens a modal with document print options.

print();