Simple dialog box

Source: Internet
Author: User

The window object provides three methods to display a simple dialog box to users:

① Alert ():Displays a message to the user and waits for the user to close the dialog box.Alert ("Welcome to JavaScript world! ");

② Confirm ():Ask the user to click an OK or cancl button to confirm or cancel the operation.Confirm ("are u sure? ");

③ Prompt ():Request the user to enter a string.Prompt ("input your password ");

Although these three dialog box methods are simple and easy to use, they are well designed to be used as little as possible. Dialog boxes like this are not common functions of the Web mode, and they are now increasingly rare, because Web browsers with higher capabilities support the scripting of the document content. Most users will find that the dialog box generated by the alert (), confirm (), and prompt () methods will damage their browsing experience. Now, the only common application of these methods is debugging: javascript programmers often insert an alert () method into the code.

Both methods confirm () and prompt () generate blocking, that is, they do not return until the displayed dialog box is closed. This means that the Code stops running when a dialog box is displayed. If the document is currently being loaded, it will also stop loading until the user responds with the required input. There is no way to block the blocking of these methods, because their return values are user input, so the method must wait for the user to input before returning.

In most browsers, the alert () method also blocks and waits for the user to close the dialog box.

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.