Setting Breakpoints

Setting a breakpoint allows you to specify where in a script you want to stop execution and start the debugger. For example, you might want to start the debugger at the beginning of a procedure or before a line that you suspect might cause an error.

You can:

To set a breakpoint on a specific line

  1. Display the document in Microsoft Internet Explorer.

  2. For client scripts, launch the debugger from the browser.

    û or û

    For server scripts, start the debugger as a standalone application, and then choose the document to work with. For details, see Starting Microsoft Script Debugger and Choosing a Document to Work With.

  3. In Microsoft Script Debugger, place the insertion point in the line where you want the breakpoint.

    Note Depending If you are setting a breakpoint in a Java program, select the entire statement.

  4. From the Debug menu, choose Toggle Breakpoint.

    û or û

    Click on the Debug toolbar.

    The line where you set the breakpoint is displayed in red to indicate that it is a breakpoint.

  5. Repeat Steps 3 and 4 for each breakpoint you want to set in the document.

  6. Switch to Internet Explorer.

  7. For client scripts, perform an action (such as clicking a button) that will start the script you want to debug.

    û or û

    For server scripts, refresh the document in the browser.

The debugger stops at the first breakpoint it encounters. You can now execute (step through) lines one by one. See Stepping Through Scripts.

Setting a break for the next script statement in a document is particularly useful for debugging scripts that are executed as part of a documentÆs OnLoad event. The script in the handler for this event has already been executed by the time the HTML document has completed loading, and any breakpoints set after the HTML document has completed loading are lost when the document is refreshed. Therefore, use the following procedure to debug script statements in an OnLoad handler.

Note You cannot use this method to set breakpoints in a Global.asa file. For information about how to debug scripts in Global.asa files, see Debugging a Global.asa File.

To set a break for the next line of script

  1. Display the document in Microsoft Internet Explorer, and then start the Script Debugger from the browser. For details, see Starting Microsoft Script Debugger.

  2. From the Debug menu, choose Break at Next Statement.

    û or û

    Click on the Debug toolbar.

  3. Switch to Internet Explorer, and then refresh the document or trigger an event that runs a script.

    The debugger stops at the first script line that is executed.

In some instances, the next statement that runs might not be in the document that you want to work with. For example, if you set a break for the next statement in one document in a frameset, the debugger will start if you trigger a script in a different document in the same frameset. In general, when you set a break for the next statement, you need to be aware that whatever script statement runs next will start the debugger.

See Also

Clearing Breakpoints

Executing Script Commands

Stepping Through Scripts

Viewing and Changing Values


© 1997 by Microsoft Corporation. All rights reserved.