0

Is there a way to exit a javascript script without tracking back through all called functions with return. Sort of like a gasp GOTO. Or maybe setting an infinite timer that does not take up too much CPU time. I want to use this to stop processing and warn user on unexpected exception/error cases.

4
  • 1
    why would you want to do this? Commented Jan 31, 2012 at 13:54
  • As far as i know, there is no exit function. Commented Jan 31, 2012 at 13:59
  • 1
    The only way to make JavaScript in a browser stop running is to use an "alert()" or "confirm()" dialog. Commented Jan 31, 2012 at 14:02
  • Pointy: after alert() javascript process still continues so how you stop that process ?! Commented Sep 10, 2015 at 13:12

1 Answer 1

2

In unexpected or exceptional cases, throw an exception. You still should have a root try/catch block so that it doesn't affect anything else.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.