The Script Debugging Process

See Also      Tasks

You can use the Microsoft® Visual InterDev debugger to test scripts written in Microsoft Visual Basic®, Scripting Edition (VBScript) and Microsoft JScript™. Debugging Web pages can be different than debugging in traditional development environments in these ways:

The Visual InterDev debugger allows you to debug in all of these scenarios. You can debug client script running in your local version of Microsoft® Internet Explorer.

Note   It is highly recommended that you do not use Active Desktop™ mode of Microsoft Internet Explorer 4.0 when you are debugging.

To debug script running in Microsoft® Internet Information Server (IIS) 4.0, you can run the debugger on your computer and attach it to a script running on the server. If the server is running on another computer, you can use remote debugging to debug script running there.

Note   For information about debugging Java components on your Web page, see the Java documentation on debugging.

Types of Errors

Debugging is about finding errors. When you work with script, you might encounter the following types of errors that require debugging:

Working in the Debugger

The basic process of debugging scripts consists of these tasks:

Note   You can't work with the debugger in Design view or Quick view of the HTML editor. To debug, switch to Source view.

To allow you to perform these tasks, the debugger includes these commands and windows:

Understanding Script Processing

Understanding how client scripts are processed and how errors are handled can help you debug client scripts successfully.

Processing Client Script

Client script is processed by Microsoft Internet Explorer. The browser calls the appropriate run-time module to process VBScript scripts or JavaScript scripts.

Client scripts are initially parsed when the Web 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.

Client script processing

If a run-time error occurs when a client script is executed, an error message is displayed and the script containing the error stops. Other client scripts in the document can still run (unless you start the debugger). If the script containing the error is called again, the error message is displayed again.

Depending on the language you are using, you might be able to include statements in your scripts to trap run-time errors and run your own error procedures. For example, in VBScript, you can use the ON ERROR statement to establish error trapping. For more details, see the documentation for your scripting language.

Processing Server Script

Most server script is not event-driven. Instead, when an .asp file is requested, the server reads the page and processes all server script from top to bottom. This includes script that is inline with HTML text, as shown in the following diagram.

Server script processing

Not all server script is executed immediately. As with client script, server script can include functions and subroutines that are executed only when they are called from other procedures.

Global.asa files are a special case. The Application_OnStart and Session_OnStart procedures in these files are executed only once for an application and for a session. Therefore, to debug these events easily, you must embed debugging statements in the file. For details, see Debugging a Global.asa File.