On Apr 1, 10:07 pm, Don Li <tatata9...@gmail.comwrote:
Hi,
A web app server package that I'm using includes a bunch of open
source UI components (heavy with javascripts). Inevitably it has
bugs, e.g. "undefined" is null or not an object.
This naturally erodes confidence for novice web users for the app in
question.
The techniques that I found and tried after research for suppressing
javascript err mgs either completely stop all the js running or
ineffective. Got an idea?
window.onerror = function(){return true;};
or (equivalent):
<body onerror="return true;">
That prevents from showing any error messages, but on the first
runtime error occurred the script execution will stop globally, as you
already properly noticed. The only workaround exists for Gecko
browsers implementing multi-threating in Javascript (it was necessary
as the whole top and middle layer of Gecko are written in Javascript).
For Gecko the execution and clean up happen only for the current
execution context, so on unhandled runtime error one may escape to a
parallel context over timeout:
window.onerror = function(){
window.setTimeout('resumeNext()',1);
return true;
}
That is a very risky way to handle anything and I would strongly
oppose to such coding moreover it's Gecko-only. Still I had to
mention.
Javascript doesn't have On Error Resume Next and similar constructs.
This way the only mean to prevent errors bubbling yet keep the script
executing is to try to wrap it in whole into try-catch block. Uhmm...
Do you really want to try that? :-)
So no, there is not anything close to what you are asking about.