Tutorial for implementing dialog boxes with JavaScript

Source: Internet
Author: User
Tags continue

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:

?

1 2 3 4 5 6 7

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:

?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.