How to suppress nagging javascript errors?


To suppress javascript error popups and warnings in your browser, just use the code snippet below:

<SCRIPT language=”JavaScript”>
<!–
function silentErrorHandler() {return true;}
window.onerror=silentErrorHandler;

//–>
</SCRIPT>

This however has some limitation, from what i had experienced. It works well in IE, to a major extend in Firefox, but not much in Opera and Safari. Hence it would be advisable you use the jquery error handling in addition, to be on the safer side:

$(window).error(function(){

return true;

});

As far as i have seen, jquery error handling function works pretty well in all the browsers.

I would recommend you to use this only in the final production stage and not during development. Just for the simple fact that during development you would want to find the javascript errors.

One thought on “How to suppress nagging javascript errors?

Feel free to leave a reply here...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s