This article mainly introduces the use of JavaScript to implement the dialog box tutorial, is the basic knowledge of JS introductory learning, the need for friends can refer to the
JavaScript supports three important types of dialog boxes. These dialog boxes can be used to raise and alert, or to be confirmed by any input or with an input from the user.
Here, we'll look at each of the dialog boxes in one place:
Alert dialog box:
A warning dialog box that is used primarily to give a warning message to the user. Just like if an input field requires some type of text, but the user does not enter a field as a validation, you can use a warning box, which provides a part of the warning message as follows:
?
However, a warning box can still be used for friendly messages. Warning box, give people only an "OK" button to select and continue.
Confirmation dialog box:
A confirmation dialog box is primarily used to put the user's consent to any option. It displays a dialog box with two buttons: OK and cancel.
If the user clicks the OK button, the window's method confirm () returns TRUE. If the user clicks the Cancel button confirm () returns false. You can use the confirmation dialog box as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13-14 |
|
Prompt Dialog Box:
When you want to pop a text box to get user input to the prompt dialog box is very useful. Therefore, it enables you to interact with the user. The user needs to fill in the fields, and then click OK.
Using the dialog box prompt () is a method that has two parameters (I) to display in the text box (Ⅱ) the label displayed in the Default string text box.
This dialog box has two buttons: OK and cancel. If the user clicks the "OK" button the Window method prompt () will return the input value from the text box. If the user clicks the Cancel button window prompt () returns NULL.
You can use the prompt dialog box as follows:
?