View Full Version : tips on debugging JavaScript errors

07-07-2004, 12:31 AM

I am new to JavaScript.
I am using IE6.

Every now and then I get JavaScript errors in my pages and I find it very difficult to find the location of the error.

I get a message saying that the error is in file: x.php on line 5, where in fact the error turns out to be in test.js on line 20!
of course I include test.js in x.php but IE doesn't know how to give the right file and line for the error!

Is there a simple and preferred way to debug such errors and get to the right file and line?


Willy Duitt
07-07-2004, 04:50 AM
Since you are using IE, have you tried using the Microsoft Script Debugger (http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&displaylang=en)?
It's a little better in that it will open a popup with the line the error appears on highlighted. But, it still takes some experience to read and properly decipher the cryptic error message.

However, I'm sure most of the other programmers here will agree that if you need to debug a script, you should use a Mozilla based browser (I use Firefox) and the javascript console which returns much better error reports....


07-07-2004, 07:56 AM