Prevent Javascript from Stopping when Error is Encountered
javascript, jquery
Solution
As others have said, continuing after an error might not be the best thing to do but you can try this:
function ignoreerror()
{
return true
}
window.onerror=ignoreerror();
More details here
The onerror event fires whenever an JavaScript error occurs (depending on your browser configuration, you may see an error dialog pop up). The onerror event is attached to the window object, a rather unusual place to take refuge in, but for good reason. It is attached this way so it can monitor all JavaScript errors on a page, even those in the section of the page.
Opera has a page with more details
Browsers supporting window.onerror
Chrome 13+
Firefox 6.0+
Internet Explorer 5.5+
Opera 11.60+
Safari 5.1+
Problem
Our product inserts a script into client's websites, kind of like a live chat box. Often, clients' websites have buggy javascript that also stops our code (the browser stops execution when errors are encountered). Is there any way to make our code still execute even though there are errors in the console about things like undefined methods or variables? Thanks for your help.