Select File > Debug in Browser > Netscape (or Internet Explorer). A browser window will open, and a Java Security window will open as well.
Click on a line in the code just before you think something is going wrong, and add a breakpoint by clicking the Set/Remove Breakpoint button or press F7.
Click on the Run button . The code will start executing, and then stop at the point at which you set the breakpoint.
Click the Step Into button (or press F10).
This will step through one line of your code at a time. You can watch what happens in the browser window with each step (Figure 13.47).
Figure 13.47 You can watch your code step-by-step.
Repeat Step 6 until you find your error or pass the problem area.
Sometimes simply stepping through your code is not enough to figure out what's wrong. You can also watch the values of variables (and even set them) in the debugger window as well.
To watch a variable's value:
Follow Steps 1 through 4 above.
Highlight the variable that you want to watch.
Click on the + (plus) button in the bottom half of the debugger window. The variable will appear in the bottom half of the window.
Press Enter (Return) or Without highlighting a variable, click on the Plus button and type the variable name. Then press Enter (Return).
Click on the Run button. The variable's value will be updated in the bottom half of the debugger window (Figure 13.48).
Figure 13.48 The variable's value is updated in the bottom pane of the debugger window.
To set a variable's value:
Follow Steps 1 through 3 in the previous list.
Click on the line in the code right after the variable gets its initial value. Click on the Set/Remove Breakpoint button.
Click on the Run button. This will run the code to the point where the variable has a value already set.
In the right column of the variable watch section of the debugger window (Figure 13.46), click on the variable's value. Type in the desired value.
Click on the Run button or the Step Into button. This will show you what happens to your page when the variable has the specified value.
If you use only the built-in behaviors, after you click the Run button, the debugger will not kick in until you actually trigger one of those behaviors.
In the next chapter we'll look at Dream-weaver Templates, which, when used properly, can add coherence and consistency to your Web site.