No matter how much you plan, or how much foresight you have, it's inevitable: At some point you'll get an error. Errors can occur when a programmer tries to use a method with an object that doesn't support it, or tries to use an object variable that has not been initialized, or simply makes a typing mistake. There are literally hundreds of errors that can occur in any given program and often more than one way to interpret the messages that the errors generate. Learning where and how an error occurred takes quite a bit of skill and patience. Luckily, most modern Web browsers have built-in debuggers to help you find and fix errors in code. This chapter will discuss the basic makeup of error messages and present many steps you can go through in order to solve the errors you inevitably encounter.
When a JavaScript error is encountered in a page opened in Netscape Navigator, a message is displayed in the browser's status bar as you can see in Figure 13.1. The message “JavaScript Error: Type "javascript:’ into Location for details" is only visible while the page is loading.
After the page loads, the message is replaced with the status "done." Unfortunately, because the error message disappears so quickly means that you often won't notice if there is an error while loading because pages viewed from your local machine will load much too quickly. If you think that there might be an error occurring in one of your pages, type javascript: into the location bar (just to the right of Go to) to bring up the JavaScript Communicator Console, shown in Figure 13.2.
Once you've opened the Communicator Console, you will find that it is a very helpful tool. Not only will it give you details on each error that has occurred in your code, but it will also let you manually execute JavaScript statements. Manually executing JavaScript statements can be helpful if you need to check the value of a variable or close a child window that is misbehaving. Any valid JavaScript statement may be run in the Communicator Console.
Another way to locate the errors on a Web page—especially if it isn't your own—is to view the source of the Web page itself. To do so in Netscape, open the View menu and select Page Source. This will bring up a separate window containing the textual source of the current page as shown in Figure 13.3.