Suppressing JavaScript errors

What is the most annoying thing you cant think of? Well ok, JavaScript error aren’t that annoying but nobody likes them. What we need is a simple script that stops all the JavaScript erros from appearing. This is a pretty simple script which is short so lets dive straight into the code.

<script>
function stoperror(){
return true
}
window.onerror=stoperror
</script>

Just stick the script into the head tag. Although the above alert method is invalid (no closing quotations), no errors will be generated. This script will suppress all potential errors in a page, so be sure to turn it off while test running a script.

Of course, a much better solution, is to actually write JavaScript that works.

Timeline

Newsletter

Don't have time to check my blog? Get a weekly email with all the new posts. This is my personal blog, so obviously it is 100% spam free.

Metadata

Tags: , , ,

This entry was posted on Thursday, December 30th, 2004 at 2:22 pm and is filed under Programming, Tech. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.