Debugging Javascript with Visual Studio 2003

To break into the debugger from a JavaScript file enter the keyword “debugger” at the location you want to break into the debugger at. Note that this will prompt you to select your choice of debugger – choose visual studio and then walk through the events / and view watches as you would when debugging the CLR.
Note that when the debugger starts, make sure you set it to debug “scripts” (where you normally select common language runtime).

Note that due to javascript being an interpreted, no program debug database is create, so you cannot debug uses the breakpoints (as with the CLR code – eg C#). Even though it appears that you can set breakpoints, these are not fired. Instead you must insert the “debugger” keyword into the relevant javascript.

In IE – to trigger debugging when there is an error in the executing javascript, tools -> internet options -> advanced tab, and uncheck “disable script debugging” – you may need to uncheck two successive checkboxes. Note that when an error is hit, you will be prompted to debug in visual studio. Note that when doing this, you may be asked to selected the type of code you wish to debug – if so, always select “script” when debugging javascript.

Web developer toolbars (not entirely to js debugging)…
Firefox web developer toolbar
IE web developer toolbar

You May Also Like

About the Author: rnowik

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.