Posted on Jan 25, 2008

Javascript Debugging in IE7

I had to log into a Windows box for the first time in a long time this week and somehow I like it even less than the last time I had to do so. The reason? As always, since MS never complies to anyone’s standards but it’s own, some of my javascript code was not working (in IE7). Of course it was previously tested in Firefox, Seamonkey, and Opera.

Anyway, like everything MS makes, it is nearly impossible to derive any debugging information from. After trying to duplicate the issue one of my users was having, I noticed that a small dialog box in the lower left hand corner of IE was telling me there was an error. Clicking on the box even gave me a line number, great. Viewing the source code and going to that line number however was a different story as the line number being shown relates to the source code in no way. In my search for a javascript debugger for IE7, I found these hideous instructions on how to enable debugging:

  1. Run C:\\Program Files\Microsoft Office\OFFICE11\MSE7.exe
  2. Wait for MS Script Editor to run and click Debug and install the debugger
  3. Close the MS Script Editor when debugger installation has finished
  4. In IE->Internet Options, click on the ‘Advanced’ tab and uncheck  “Disable Script Debugging (other)” and “Disable Script Debugging (Internet Explorer)”.
  5. Restart IE

The next time you encounter the error, you will get a dialog box asking if you want to debug. Choosing ‘yes’ and ‘MS Script Editor’ for your debugger will give you some debugging ability (it actually shows you the line where the error occurs). Certainly much more complicated than it should be, but anyone who writes javascript has to use it. On a better note, I have an even greater appreciation for firebug.

Note to self: write all your web apps using Google Web Toolkit from now on so you don’t have to worry about browser incompatibilities.