Skip to content Skip to sidebar Skip to footer

How To Suppress All Javascript Runtime Errors?

How can I suppress all JavaScript runtime error popups, from the programmers side?

Solution 1:

To suppress all JavaScript errors there seems to be a window.onerror event. If it is replaced as early as possible(e.g. right after the head) by a function which returns true - there will be no error popups, which is quite useful after debugging is done.

<head><scripttype="text/javascript">window.onerror = function(message, url, lineNumber) {  
        // code to execute on an error  returntrue; // prevents browser error messages  
    };
</script> 
...

Error Logging is possible too, as explained here

Solution 2:

I made a little script for suppressing an error like "@" does in PHP.

Here is an example.

var at = function( test ) {
    try {
        if(typeof test === "function") returntest();            
        elsereturn test || null;        
    } catch (e) {
        returnnull;
    }
};

Post a Comment for "How To Suppress All Javascript Runtime Errors?"