views:

19144

answers:

11

I need to debug JavaScript in Internet Explorer 7.

Unfortunately, its default debugger doesn't provide me with much information. It tells me the page that the error showed up on (not the specific script) and gives me a line number. I don't know if that is related to my problem.

It'd be nice if it could narrow down the error to a line number on a specific script (like Firebug can).

Is there an addon to debug JavaScript in IE7 like Firebug does in Firefox?

Thank you!

See also:

Does IE7 have a “developer mode” or plugin like Firefox/Chrome/Safari?

+5  A: 

I've found http://www.debugbar.com

Not as good as Firebug

alex
still, way better than ie dev toolbar
Sam Saffron
A: 

i have heard of a javascript file you can include in the web page that does the same thing, but nothing that works straight from the browser a la firebug. I think its called firebug lite

Not nearly as good as Firebug for Firefox.
alex
of course its not nearly as good as firebug for firefox. It is trying to emulate firebug for IE.
I don't try to be.
alex
If you read my question, I asked if there was something similar to Firebug (a browser addon). That's why I posted that comment. I don't think I deserved 'are you stupid?'
alex
yea i know, sorry, i read the question as "I am looking for X in IE.". And then your comment to me was "Its not as good as X in FF". And I was thinking, "ok, but we are talking about IE here". Here, let me visit your site, ill give you some traffic.
Apology accepted. Traffic to my site isn't necessary, it's more a work in progress and I'm not interested (at this stage) in driving traffic to it.
alex
+19  A: 

IE Dev Toolbar and Web Development Helper are very good.

Bob
+4  A: 

IE8 has much improved developer tools. Until then it's best to write javascript for firefox first and then debug IE using alert() statements.

Joel Coehoorn
Can't wait for IE8 (so long as it lives up to the hype - I've yet to download the beta)
alex
Now that it's out I've udpated, and I must say that I like the debugger even better than firebug's :)
Joel Coehoorn
@Joel, although the debugger is great - one thing that annoys me (that Firebug has) is a right click context menu where you can choose "inspect element". To my knowledge, in IE8 you have to launch the developer tools, then click the arrow, then find the element you want to inspect.
alex
+12  A: 

The hard truth is: the only good debugger for IE is Visual Studio.

If you don't have money for the real deal, download free Visual Web Developer 2008 Express Edition. While the former allows you to attach debugger to already running IE, the latter doesn't (at least previous versions I used didn't allow that). If this is still the case, the trick is to create a simple project with one empty web page, "run" it (it starts the browser), now navigate to whatever page you want to debug, and start debugging.

Microsoft gives away full Visual Studio on different events, usually with license restrictions, but they allow tinkering at home. Check their schedule and the list of freebies.

Another hint: try to debug your web application with other browsers first. I had a great success with Opera. Somehow Opera's emulation of IE and its bugs was pretty close, but the debugger is much better.

Eugene Lazutkin
+6  A: 

hi, you might want to try microsoft script debugger it's pretty old but it's quite useful in the sense if you stumble on any javascript error, the debugger will popup to show you which line is messing up. it could get irrating sometimes when you do normal surfing, but you can turn if off.

here's a good startup on how to use this tool too. HOW-TO: Debug JavaScript in Internet Explorer

melaos
+1  A: 

Microsoft Script Editor can be used to debug Javascript in IE. It's less buggy than Microsoft Script Debugger but has the same basic functionality, which unfortunately is pretty much limited to stepping through execution. I can't seem to inspect variables or any handy stuff like that. Also, it only shipped with Office XP/2003 for some bizarre reason. More info here if you're game.

I downloaded the Visual Web Developer 2008 Express Edition mentioned by Eugene Lazutkin but haven't had a chance to try it yet. I'd recommend trying that before Script Editor/Debugger.

Kenny
+1  A: 

It's not a full debugger, but my DP_DEBUG extensions provides some (I think) usful functionality and they work in IE, Firefox and Opera (9+).

You can "dump" visual representations of complex JavaScript objects (even system objects), do simplified logging and timing. The component provides simple methods to enable or disable it so that you can leave the debugger in place for production work if you like.

DP_Debug

+1  A: 

Microsoft Script Editor is indeed an option, and of the ones I've tried one of the more stable ones -- the debugger in IE8 is great but for some reason whenever I start the Developer Tools it takes IE8 a while, sometimes up to a minute, to inspect my page's DOM tree. And afterwards it seems to want to do it on every page refresh which is a torture.

You can inspect contents of variables in Microsoft Script editor: if you poke around under Debug > Window you can turn on local variable inspection, watching etc.

The other option, Visual Web Dev, while bulky, works reasonably well. To set it up, do this (stolen from here):

  1. Debugging should be turned on in IE. Go into Tools > Internet Options > Advanced and check that Disable Script Debugging (Internet Explorer) is unchecked and Display a notification about every script error is checked
  2. Create a new empty web project inside of VWD
  3. Right-click on the site in the Solutions Explorer on the top right, go to Browse With and make sure your default browser is set to IE (it's reasonable to assume if you're a web developer IE is not your default browser in which case that won't be the default.. by default)
  4. Hit F5, IE will open up. Browse to the page you want to debug.
  5. VWD will now open up any time you have a script error or if you set a breakpoint in one of the JS files. Debug away!

UPDATE: By the way, if you experience the same slowdowns as me with IE8's otherwise decent debugger, there is a workaround -- if you encounter or make IE encounter an error so that it pops up the "Do you want to debug" dialogue and hit Yes, the debugger will come up pretty much instantly. It seems like if you go "straight" into debugging mode the Dev Tools never inspect the DOM. It's only when you hit F12 that it does.

mitjak
I'd have to test this out some more but so far it seems like the IE8 debugger works faster when browsing in compatibility mode. Go figure!
mitjak
+3  A: 

Use Internet Explorer 8. Then Try the developer tool.. You can debug based on IE 7 also in compatibility mode

joberror
IE7 != IE8 compat mode. There are incompatibilities.
thorn
+1 At least IE8 tells you the file name of the script that's causing the error.
Colonel Sponsz
+2  A: 

In IE7, you can bring up firebug lite for the current page by pasting the following in the address bar:

javascript:var firebug=document.createElement('script');firebug.setAttribute('src','http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js');document.body.appendChild(firebug);(function(){if(window.firebug.version){firebug.init();}else{setTimeout(arguments.callee);}})();void(firebug);

See http://getfirebug.com/lite.html.

Marc

Marc