Most likely, the solution is simple: your code doesn't work under the debugger as well, but you fail to notice that, because the debuggers gives you some information on what's going, on, but "normal" operation of the JavaScript in browser simply "swallows" the exceptions and seize the operation.
One apparent approach to development is: handle the exceptions. Basically, it would be enough to handle all exceptions on top stack frame of your code of the
<body>
element, if any, plus on top stack frame of the code of each event handler. Then you need to present the exception information the way it does not throw exceptions itself.
This might be not enough. Some problems of your code can be
lexical. They won't be caught as exceptions in a usual way. But I have one secret weapon:
eval
. The technique is described in detail in my article, the section "5 Handling Lexical Errors":
JavaScript Calculator[
^].
In the same article, you can find more detailed advice and code for exception handling.
—SA