Tutorial by Examples

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...
When using prompt a user can always click Cancel and no value will be returned. To prevent empty values and make it more persistent: <h2>Welcome <span id="name"></span>!</h2> <script> // Persistent Prompt modal var userName; while(!userName) { userN...
A way to use confirm() is when some UI action does some destructive changes to the page and is better accompanied by a notification and a user confirmation - like i.e. before deleting a post message: <div id="post-102"> <p>I like Confirm modals.</p> <a data-dele...
The alert() method of the window object displays an alert box with a specified message and an OK or Cancel button. The text of that button depends on the browser and can't be modified. Syntax alert("Hello world!"); // Or, alternatively... window.alert("Hello world!"); Prod...
Prompt will display a dialog to the user requesting their input. You can provide a message that will be placed above the text field. The return value is a string representing the input provided by the user. var name = prompt("What's your name?"); console.log("Hello, " + name); ...

Page 1 of 1