How do you debug IE and jQuery errors like this?

I have been developing in Javascript for quite some time. Usually, when I find an error in IE, I know roughly where it came from, even if the message received from IE is a useless bunch of text. When I don’t know where the error came from, I usually try to “delete” parts of my code until the error repeats itself, and which will start manually checking line by line until I find the error.

I'm sure this is far from the best approach, so I would like to ask you how you are debugging errors like these: Errors on webpage - Internet Explorer

+4
source share
3 answers

If you are using IE8 +, you can press F12 on the page to open the Developer Tools.

It contains a JavaScript debugger similar to Firebug and Chrome Dev Tools

EDIT: In response to the comment in the question, if IE throws a cryptic error that you don't know about, there are a few steps that I would take.

  • Is this just an IE bug? Did the same error occur in Firefox? Chrome?
  • An error has occurred in a third-party library. If you think so, use an invalid version of the library.
  • Can you repeat the error outside your website? Can you make a mistake in http://jsfiddle.net/ for example?
  • If you still can’t narrow down the issue, submit a SO question with code, error messages, and result expectations.

NTN

+7
source

Try using an invalid version of jQuery - this will give you a better idea of ​​exactly where the error is. Also, if you use VS 2010 to debug your js code in IE, it will break on the error line. It always works well for me.

+1
source

IE is the only browser I've been able to successfully use the fantastic Visual Studio script debugger with - in my experience, Visual Studio compresses the debugger the best script there, so quite often I find myself in the opposite situation with you (running broken scripts in IE so that I can use debugger script)

See How to Debug JavaScript in Internet Explorer for instructions on how to use Visual Studio Express to debug scripts in IE - if you have a full edition of Visual Studio, then it is much simpler (just attach it to IE as usual).

0
source

All Articles