Methods that abort javascript execution

  • 2020-03-30 01:46:06
  • OfStack

JS has no PHP exit and no JAVA return.

If the JS code is not a function, it needs to abort the execution of JS. There is only one way:

Document. The location. Href = your_url;

In addition, throw can abort, but it is still an unfriendly error message, so if you want to abort friendly, the only way is the above method.

Therefore, the non-functional mode of the code, is not able to stay at the current page to achieve termination.


Related articles: