views:

282

answers:

10
+1  Q: 

JScript debugging

I have a few scripts on a site I recently started maintaining. I get those Object Not Found errors in IE6 (which Firefox fails to report in its Error Console?). What's the best way to debug these- any good cross-browser-compatible IDEs, or javascript debugging libraries of some sort?

+1  A: 

Firebug

It's only for firefox but it should let you figure out what's happening on IE especially once you have the script line numbers.

William
+3  A: 

There's no cross-browser JS debugger that I know of (because most browsers use different JS engines).

For firefox, I'd definitely recommend firebug (http://www.getfirebug.com)

For IE, the best I've found is Microsoft Script Debugger (http://www.microsoft.com/downloads/details.aspx?familyid=2f465be0-94fd-4569-b3c4-dffdf19ccd99&displaylang=en). If you have Office installed, you may also have Microsoft Script Editor installed. To use either of these, you need to turn on script debugging in IE. (uncheck Tools -> Internet Options -> Advanced -> Disable Script debugging).

mopoke
A: 
  1. You can use Visual Studio and enable debugging in browser
  2. You can install FireBug plugin for Firefox, it's really good!
  3. You can try to install IE8 beta 2 and use it in compatibility mode with built-in debugger.

Also in any line of your JS code you can write

debugger;

and this will be threated as breakpoint for any of the debug tools you use.

Cheers!

dimarzionist
A: 

You could use this tool apparently - Microsoft Script Debugger

Personally I try to go through the code and figure out what's going on - it gives you the line number where it goes wrong right?

Svet
+1  A: 

Aptana Studio provides JavaScript debugging for Firefox and IE

David Negron
+1  A: 

Firebug is the best all around client-side debugger. I frequently use it to debug CSS code as well as javascript. It allows you to easily find offending areas of code. I especially like the ability to modify tag attributes in the firebug pane and see the effects immediately before committing. Very useful for anyone designing websites.

madcolor
+2  A: 

You could also use Firebug Lite - which will work in IE & Opera. It's an external lib that will help you track down problems. It's sometimes more convenient than dealing with the MS Script Debugger.

Darren Newton
A: 

To make the Microsoft Script Debugger more user friendly (and to add javascript error messages that actually are helpful to IE), I highly recommend Companion.JS.

Kristian J.
A: 

Firebug seems to be the most useful so far. When a page is running on firebug, it can be very handy to log messages into firebug via javascript calls to console.log('your log message'); but don't execute that code in IE since the console object is only in scope when firebug is running.

For IE, other folks have mentioned the Script Debugger. Although it is not primarily for javascript debugging, it can be useful to also add the IE developer toolbar, which allows you to easily and dynamically inspect the style and other properties of your page's DOM.

Tyler
A: 

In response to mopoke, for IE6 you definitely want to use Visual Studio for debugging if you can get it. For all intents and purposes, the MS script debugger is useless. You're better off using some form of tracing (not alerts) than using the MS script debugger. Dojo Toolkit, for instance, provides a debug console for tracing, but you can write your own by dumping messages to a secondary window or div.

The script debugger needlessly prompts you on each error in IE6 and even then doesn't give you enough state context to make it useful in a sufficiently complex JS app. Visual Studio is more tightly integrated and much friendlier. Just my experience.

Glenn
I think Visual Studio is a bit of overkill for many. If I'm developing in PHP or Java, Visual Studio is like installing "Pepsi" to get my "Coke" working.
scunliffe