Friday, January 13, 2006

Tip: the MS Script Debugger

I'm surprised that more JavaScript developers don't know (or maybe have forgotten) about the Microsoft Script Debugger. If you're weary of IE script errors that report "Line 324: Object expected" and no filename when you have 500K of script divided over 12 files, install this beastie, then open IE and go to Tools > Internet Options > Advanced and uncheck "Disable Script Debugging (Internet Explorer)."

Restart IE and the next time you encounter a JS error, a dialog box should pop up asking you if you wish to debug it. Clicking OK will launch the debugger, taking you to the file (hallelujah!) and the line at which it occurred.

It's not specifically tailored for JS like Venkman, but it's waaaaay better than IE's native JS error reporting.

9 Comments:

At 2:30 AM, Blogger Stuart Langridge said...

The reason I *stopped* using the debugger was that shutting down the debugger also shut down IE. That's the most annoying thing in the world. Has that been fixed now? Must test it again.

 
At 5:19 AM, Blogger Brent Ashley said...

Stuart - I think that has changed now, however I think the "Debug...Stop Debugging" menu item would detach from the process so you could close the window without killing IE. Certainly, if you're debugging with Visual Studio, you can select "Debug...Detach all processes" from the menu with that effect.

The Visual Studio debugger is pretty well every bit as good as and sometimes better than Venkman but for IE. In VS 2005, you don;t even have to add vars to the watch window, you can hover and get a popup of a full object tree.

I'm certainly not an MS-worldview advocate, but you'd be missing out if you didn't try Visual Studio for Javascript debugging.

 
At 8:32 AM, Blogger scottandrew said...

I seem to remember that just clicking the [X] button on the debugger would take down IE with it, but recently I find if I do File > Close instead, it leaves IE running. (Maybe it's always done that.)

 
At 10:13 AM, Blogger David said...

If you have Visual Studio or Office you are much better off using them for debugging (debugging via office). The Office and VS debuggers are the same and are infinitely more useful than the MS Script Debugger.

 
At 10:16 PM, Blogger splintor said...

Note that browser based on IE, such as Avant Browser or Maxthon, turn on the "Disable Script Debugging" option when they start. Very annoying, and one of the reasons I swtiched to Firefox for tabbed navigation.

Maxthon have an option to disable this annoying behavior, though.

 
At 7:51 AM, Blogger Rich Grimmer said...

Wow - YOU guys might be able to help..CAN'T get script dbg working on my Dev box - have enabled script debugging in IE, at my App level in IIS and have given create IIS Process user debug rights...no matter WHAT I do, every time I try to debug, MSD pops up, but with no document. Running docs, Call stace etc always empty....am I missing something here?

MY GOD I HOPE YOU CAN HELP - this is driving me batty!

 
At 7:49 AM, Blogger Ian said...

The reason I no longer use the MS Script debugger is because when you install it, you also appear to install a scripting engine that's slightly different from the one that comes as standard with Windows.

This means you risk users seeing bugs that never appeared in your devlopment environment. That sucks.

 
At 9:57 AM, Blogger Tippfehler said...

A useful feature when debugging a large document with MS Script Debugger is setting bookmarks. Pressing CTRL+F2 toggles a bookmark on the current line. To navigate from bookmark to bookmark, press F2 to move forward, or SHIFT+F2 to move backward.

Greetings, Peter
Tippfehler

 
At 11:56 AM, Blogger Scott said...

Maybe if IE's javascript engine wasn't a giant piece of crap, we wouldn't be as reliant on debuggers as we are now.

 

Post a Comment

<< Home