Troubleshooting JavaScript Errors

Troubleshooting JavaScript errors can be difficult. Most errors are subtle and not very apparent. However, even the most subtle error can render the JavaScript code on a page inoperable. Fortunately, most browsers have built-in JavaScript troubleshooting tools that make the job much easier.

It may not come as any surprise that Netscape, FireFox and Mozilla-based browsers have the best JavaScript tools. After all, it was Netscape who originally developed JavaScript. Contrary to a popular misconception, JavaScript has no relationship with Java. Java was developed by Sun Microsystems and JavaScript is not the script form of Java. JavaScript was originally called LiveScript, but Netscape changed the name to capitalize on the then popular and emerging Java programming language.

Let’s start with Internet Explorer. Although this JavaScript troubleshooting tool is clearly not the best, it can be used to identify problems. Most people are not even aware that it exists because it is disabled by default.

To enable Internet Explorer’s JavaScript Troubleshooting Tool

  • Select Tools from IE’s top menu.
  • Select Internet Options
  • Select the Advanced tab
  • Under the Browsing category, uncheck Disable Script Debugging
    (Internet Explorer)

Whenever a JavaScript error is generated, Internet Explorer will now display a message box with a few sometimes cryptic messages about the error. The information regarding the type of error is usually accurate. The exact location of the error in a script is frequently not.

All Mozilla-based browsers, including Mozilla, Netscape and FireFox have a very useful JavaScript troubleshooting tool called the JavaScript Console. Although the JavaScript Console can be enabled through the browser menus in newer versions of Mozilla-based browsers, there is one standard method that is easy to use and works universally with all of the
Netscape-Mozilla family of browsers.

To Enable the JavaScript Console in Mozilla or FireFox

  • Open your Web application in your browser
  • Enter javascript: in the address box (do not use
    http://) or select "JavaScript Console" under the Tools menu.
  • The JavaScript Console will open as a separate window

The JavaScript Console will record and display useful details about any JavaScript errors it encounters. This tool does not validate the code; it detects errors upon execution of the code. This makes it much easier to detect errors based upon your interaction with your script.

Give it a try. You’ll like it.