JavaScript implementation _javascript tips for determining and canceling prompt box effects

Source: Internet
Author: User

In many pages have this effect, when clicked on a button or other objects will pop up a prompt box, if click OK to continue to execute the established program, if click Cancel will cancel continue execution, the code example is as follows:

<! DOCTYPE html> 
 
 

The above code, when clicked on the link will pop up a prompt box, if click OK will visit Ant Tribe home page, otherwise will not visit. The core of this functionality is the use of confirm (), which is the text content of the prompt box. Here is a brief introduction to the principle of the above code:

When clicking on a link, the onclick event handler that is bound to a element is called.

Two. In the event handler function, the Confirm () returns true when clicked on the OK button, and the click Cancellation returns False, then the IF statement chooses whether to execute an if statement or an else statement based on the return value of confirm ().

The above mentioned is the entire content of this article, I hope you can enjoy.

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.