advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Download the code for this article
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement

Eliminate Irritating JavaScript Errors

No one likes those irritating JavaScript error messages, but to eliminate them you must add client-side error handling to your scripts, or, risk losing your audience. 


advertisement
ou come home, turn on the computer, pull up a Web site, click on a link and HALT! A JavaScript alert box pops up; telling you there is a runtime error, and asking, "Do you wish to debug?" Well that message is fine for developers, but what about the end-users—your audience? The truth is the audience expects the Internet to be quick, easy and free. When they see errors, they mostly don't know what to do, so they take the path of least resistance—by closing the Alert box and clicking a different link or, worse, leaving your site altogether.


To avoid this problem, you need to learn how to avoid the typical JavaScript error messages, discuss their common causes, and how to trap and handle them so you don't lose your audience.

JavaScript can raise object or syntax errors for several reasons: bad user input, bad data types, or simple typos in your code. By default, all JavaScript errors (depending on the browser version and the settings) produce an alert dialog asking users if they wish to debug. The dialog displays the line number and an error message, such as "Object expected" or "Character Expected" and (in some cases) shows additional information—such as the missing character. Netscape Navigator and Internet Explorer handle errors differently, so I'll show you ways to trap and handle errors in both browsers.

It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement