Home>Article>Web Front-end> javascript has several dialog boxes

javascript has several dialog boxes

青灯夜游
青灯夜游 Original
2021-06-17 14:08:00 2805browse

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

javascript has several dialog boxes

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:

javascript has several dialog boxes

##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:


javascript has several dialog boxes

##Prompt box: prompt()

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:

javascript has several dialog boxesFor more programming-related knowledge, please visit:

Programming Video

! !

The above is the detailed content of javascript has several dialog boxes. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn