Debugging Client Script

See Also

You can debug client script by running it from within your Microsoft Visual InterDev solution, or by responding to a syntax or run time error in a script, called just-in-time debugging.

Note   To debug client script in Microsoft Internet Explorer, you must be using Internet Explorer 4.0. Debugging must also be enabled in Internet Explorer (this is the default). It is also highly recommended that you do not use Active Desktop mode of Internet Explorer when you are debugging.

If the script is in a file that belongs to a project in the current solution, you can fix the error, and then restart the debugging session to see the effect of your change. If the error is in a page that does not belong to the current solution, you can view the script in a read-only window.

Before you can debug client script in ASP pages, you must enable debugging.

To enable client script debugging in ASP pages

  1. In the Project Explorer, right-click the project and choose Properties to display the Property Pages dialog box.

  2. Choose the Launch tab.

  3. Under Server script, choose Automatically enable ASP client-side debugging on launch.

Note   To debug script in ASP pages, you must be running version 4.0 or later of Microsoft Internet Information Server (IIS).

If a Web page contains a mixture of client and server script, you can use the Visual InterDev debugger to debug both. For details, see Debugging Mixed Client and Server Script.

To debug a script from within a solution

  1. In Visual InterDev, open the project containing the page you want to debug, and load the page into the editor.

  2. Make the page your project's start page. In the Project Explorer, right-click the page and choose Set as Start Page.

  3. Set a breakpoint in the script to debug. For details, see Setting Breakpoints.

  4. From the Debug menu, choose Start.

    Visual InterDev launches Internet Explorer and loads the page into it. If the breakpoint is in an event handler script, you might have to trigger the event. When Internet Explorer reaches the breakpoint, it stops and displays the source code in the editor window.

  5. If you find an error, fix it, and then save the file. If you do not have a working copy of the file, right-click the name of the file in the Project Explorer and choose Get Latest Version before you make modifications.

  6. From the Debug menu, choose Restart.

Tip   You can also add a Stop statement (in VBScript) or a debugger statement (in JScript) to launch the debugger from within a script.

If a client script is already running in Internet Explorer and you detect a problem, you can stop the script and debug it on the spot.

To debug a running script

If Internet Explorer encounters a syntax or runtime error, you can use just-in-time debugging to find and fix it.

To debug in response to an error