JavaScript Pop-up box: Warning (Alert), Confirmation (confirm), and questions (prompt)

Source: Internet
Author: User
Warning (alert)

Did you ever get into a situation like this when you visit a website? "Boom", a small window appears in front of you, with a piece of warning text written, or other information. If you don't click OK, you won't be able to do anything with the page. Yes, this little "boom" window is alert.

The following code is an instance of using alert.

 

My personal view is to use alert as little as possible and it is unfriendly. It may even make some parties think your site is dangerous.

Look at an instance confirmation using Alert (confirm)

A confirmation box is used to let the user choose whether a problem is realistic.

Said Yes or No. Quick answer. ”

If you want to express such meaning, then confirm is more suitable. Look at the following code: we use confirm ("Are you a rookie?"). To ask the visitor, variable R saves the visitor's response, and it can only have two values: TRUE or FALSE. Yes, it's a Boolean value. The statement behind confirm is a different response to our visitors ' answers.

 

Look at an instance of using Confirm (prompt)

Prompt is similar to confirm, but it allows visitors to enter the answer at random. Let's revise the example of the previous switch, and we'll make a different evaluation based on the score, but the procedure is not complete, it doesn't ask us for a score, it's supposed to be 65 points. It's not fair. Now I can use prompt to ask visitors questions, use score to store user input answers, and the rest is done by the switch behind.

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.