HTML and CSS Reference
Debugging Tools and Techniques
There are several techniques you can employ to avoid making programming mistakes
and to quickly locate the mistakes you do make. One is to write modular code , which is
code that breaks up a program's different tasks into smaller, more manageable chunks.
A common strategy when creating modular code is to use functions that perform a few
simple tasks. The different functions can then be combined and used in a variety of ways.
If you encounter a logical error in which the incorrect results are displayed by the
browser, you can monitor the changing values of your variables using an alert dialog box.
with an OK button. Clicking the OK button closes the dialog box, allowing the browser to
alert( text );
where text is the text string that you want displayed in the dialog box. You can also use
a variable name in place of a text string. For example, the command
displays the current value of the emLink variable. Figure 10-31 shows the appearance of
this dialog box for the first entry in the library staff directory. Alert dialog boxes are useful
in determining what is happening to your variable values while a program is running.
Alert dialog box
you can open the Developer Tools window by pressing the F12 key. From this window you
can run a script debugger to locate and describe any load-time or run-time errors in your
code, as shown in Figure 10-32.
internet explorer Developer tools window