• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Debugging Your JavaScript

Dreamweaver includes a JavaScript debugger, which allows you to find problems in your JavaScript code. Even if you’re just using the built-in behaviors, there are times when they don’t do exactly what you expect, and the debugger can be a valuable tool to find the problem.

To use the JavaScript debugger:

1.
Open the page with the JavaScript you want to debug.

2.
Select File > Debug in Browser > Netscape (or Internet Explorer). A browser window will open, and a Java Security window will open as well.

3.
If you’re debugging in Netscape Navigator, click on OK in the debugger warning box that appears, then click on Grant in the Java Security dialog box. If you’re using Internet Explorer (Windows only, the debugger doesn’t work on Internet Explorer for Macintosh), click on Yes in the Java Security dialog box, then on OK in the debugger warning box that appears.

The debugger window will appear (Figure 13.46), and the browser will stop at the first line of JavaScript code.

Figure 13.46. The JavaScript debugger window.


4.
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.

5.
Click on the Run button . The code will start executing, and then stop at the point at which you set the breakpoint.

6.
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.


7.
Repeat Step 6 until you find your error or pass the problem area.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint