Client Script Debugging

Understanding how scripts in HTML documents are processed and how errors are handled can help you debug client scripts successfully. To debug scripts in HTML documents, you run Microsoft Script Debugger on your client computer and attach it to a document currently running in Microsoft Internet Explorer or Outlook.

Note To debug client scripts in Microsoft Internet Explorer, script debugging must be enabled. For details, see the Internet Explorer documentation.

Processing Client Script

Client scripts (scripts in an HTML page) are processed by a browser such as Microsoft Internet Explorer. The browser calls the appropriate runtime module to process VBScript scripts, JScript scripts, or Java applications.

Client scripts are initially parsed when the HTML document is loaded into the browser. During this parsing phase, the browser reports any syntax errors that it finds.

After parsing a section of script, the browser executes it. Global or inline scripts, which are scripts that are not part of an event-handling subroutine or function, are executed immediately. Event-handling subroutines or functions, and procedures that are called by other procedures, are parsed immediately but are not executed until triggered by an event or called by another procedure.

If a runtime error occurs when a client script runs, an error message is displayed and the script containing the error stops. Other scripts in the HTML document can still run. If the script containing the error is called again, the error message is displayed again.

Using the Script Debugger with Client Scripts

If an error occurs in a client script, Microsoft Internet Explorer displays an error message indicating the error and the line on which it was found, as in the following illustration:

If you choose to debug, Internet Explorer starts the debugger and displays the script in a read-only window. You can navigate in the document, set breakpoints, return to the document to run scripts and step through them. If you refresh the document, you will lose any breakpoints you have set. However, you cannot directly edit the source code in the debugger. If you have access to the original document file (the .htm file), you can make changes to that file and then reload it in the browser

Note If you are debugging a client script generated by an .asp file, the line numbers reported in error messages refer to lines in the HTML document currently displayed in the browser. These usually do not correspond to line numbers in the original .asp file, because server script does not appear in the HTML output of an .asp file.

See Also

Debugging Scripts

Server Script Debugging

Starting Microsoft Script Debugger


© 1997 by Microsoft Corporation. All rights reserved.