Ways to abort JavaScript execution

Source: Internet
Author: User

This article is mainly to stop the JavaScript implementation of the method is introduced, the need for friends can come to the reference, I hope to help you

JS does not have PHP exit, there is no Java return.

If the JS code is not a function, you need to abort JS execution, there is only one way, that is:

Document.location.href=your_url;

In addition, although throw can be terminated, but is still an unfriendly error message, so if you want to be friendly to stop, can only be the above method.

Therefore, the non functional pattern of the code is unable to stay on the current page implementation aborted.

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.