Adding Your Own Error Handler
Question: Can I set up my own JavaScript error handler?
Answer:
Yes. To define your own error handler, use this JavaScript code:
function handlerFunction(description,page,line) {
// put error-handling operators here
return true
}
window.onerror=handlerFunction
Your error handler function can optionally use the following parameters:
a textual description of the error
the address (URL) of the page on which the error occurred
the number of the line in which the error occurred
The error handler function must return false
if you
wish to invoke the browser's default error handler after
your own handler finishes. If you don't want to invoke
the browser's default handler, your handler function must return
true
. For an additional code example,
check out our error handling demo!
JavaScripter.net.
Copyright
© 1999-2006, Alexei Kourbatov