Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The JavaScript FAQ
Prev Home Next

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

    The JavaScript FAQ
    Prev Home Next


  •  
     
      Mirrored with kind permission of Alexei Kourbatov Design by Interspire