Engage on Facebook Engage on Twitter Engage on LinkedIn Engage on GitHub

Debugging JavaScript on Internet Explorer

By Brian Dukes

If you're anything like me, you've been greatly looking forward to Visual Studio Orcas, with its enhanced support for JavaScript.  You might also not know that some of that functionality is available to us currently in Visual Studio 2005.  It's not exactly easy to setup and use, but once you get it going, it can really help out when you're trying to figure out why, for example, all elements on your page suddenly disappear, only in IE.

Using this Knowledge Base article as a starting point, http://support.microsoft.com/kb/816173, I was able to get up, running, and debugging.  The first step is to enable debugging from Internet Explorer, by unchecking the "Disable Script Debugging (Internet Explorer)" box in IE's Advanced Options.  Then, in order to actually set a breakpoint and step into your javascript code, you'll need to use the debugger keyword in your code.  Just put that statement in your script wherever you would like the debugger to break, and it'll throw a script exception and ask which program you'd like to debug in.  After choosing Visual Studio 2005, it's pretty much just like a normal .NET debugging experience.  You can walk into functions, you can set Watches on variables and do QuickWatches.  You can hover over variables to see their current value.

The JavaScript support in Visual Studio 2005 can be spotty and incomplete, but it's definately better than nothing.  That said, if it's not an IE specific problem, you should probably be using Firebug or Venkman inside of Firefox.

Hope it helps!

Planning a DNN upgrade? Download our guide