Home>Article>Web Front-end> javascript has several dialog boxes
Javascript has 3 dialog boxes: 1. Warning box, used to display warning messages to users, with the syntax "alert("warning message");"; 2. Confirmation box, with the syntax "confirm("requires confirmation Information ");"; 3. Prompt box, syntax "prompt("prompt information", "default text");".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
JavaScript uses three types of dialog boxes: warning box, confirmation box and prompt box; corresponding to three functions: alert(), confirm(), prompt(). These dialog boxes are very helpful in making our website look more attractive.
Warning box: alert()
The warning box in the website is used to display a warning message to the user, indicating that they have entered the wrong value and are not filling in the position. required value. Still, alert boxes can be used for friendlier messages. The alert box only provides a button "OK" to select and continue.
Example:
点击按钮
Rendering:
##Confirmation box: confirm()
If you want the user to verify or accept something, a confirmation box is typically used. When the confirmation box pops up, the user must click OK or Cancel to continue. If the user clicks the "OK" button, the window method confirm() will return true. If the user clicks the Cancel button, confirm() returns false and displays null. Example:Rendering:点击按钮
If you want the user to enter a value before entering the page, you will usually use a prompt box. When the prompt box pops up, the user must click "OK" or "Cancel" to continue entering values. If the user clicks the "OK" button, the window method prompt() will return the entered value from the text box. If the user clicks the "Cancel" button, the window method prompt() will return null.
Example:
点击按钮
Rendering:
For more programming-related knowledge, please visit:
Programming VideoThe above is the detailed content of javascript has several dialog boxes. For more information, please follow other related articles on the PHP Chinese website!