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 server scripts ù scripts in ASP pages ù you must run Microsoft Script Debugger on the same computer that is running Microsoft Internet Information Server (IIS). For details, see Server Script Debugging.
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 programs.
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.
[Need DcScrClt.bmp here]
If a runtime error occurs when a client script runs, an error message is displayed and script execution stops. The remainder of the HTML document can continue to run. If the script containing the error is called again, the error message is displayed again.
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 view the source, Internet Explorer starts the debugger and displays the script in a read-only window. You can navigate in the document, set breakpoints, and run the document again. 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 page, 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 page, because server script does not appear in the HTML output of an ASP page.
See Also