Now that we know how to detect when an error has occurred (by using the
onerror event), we can suppress them. Simply have your function
attached to the
return true at the
very end. The
following modifies the example on the last page so the default error message is
alert('An error has occurred!')
onerror event with a function that returns a value of
true at the very top of your page suppresses all
scripting errors on the page .
Be careful when using the
onerror event this way, since it only
suppresses errors, but doesn't fix them. Even humans have trouble with the
later! Whenever testing codes in your browser, make sure to first turn off
the error suppressor , or you may even be fooled by your foul scripts!