8

I saw several specific questions about this problem - getting typeerror object doesn't support this property or method in IE8, each with its specific answer.

Suppose I have a large website with lots of code ... I don't know what specific snippet is causing this error.

Is there a general method to debug this? I've tried with the IE Developer Tools, and it doesn't break on error. Is this caused by incorrect javascript syntax? Should I try something like js lint?

What's the correct, general way to identify and deal with this problem?

ripper234
  • 202,011
  • 255
  • 600
  • 878
  • `typeerror` couldn't be a `syntaxerror`. One is able to debug it in build-in debugger, just need to enter debug mode. – kirilloid Mar 09 '12 at 09:51
  • 3
    @kirilloid - so you suggest I just step through the entire code base? I guess that's one option. God I hate IE. – ripper234 Mar 09 '12 at 10:21
  • No. Once you enter debug mode, it will automatically stop on errors and you'll be able to look around and inspect all values, preceding the error. – kirilloid Mar 09 '12 at 10:44
  • 5
    @kirilloid - do you mean the Dev Tools? (F12) That's what I've tried, and it does't stop on the error. – ripper234 Mar 09 '12 at 11:01
  • @kirilloid - well, it doesn't work for me. I've Started Debugging, and immediately get this error when I refresh the page. – ripper234 Mar 09 '12 at 12:35
  • I wish browser development/debugging was more evolved. You should mitigate this situation by unit-testing the code, that should be able to identify the issues. – Tengiz Oct 21 '14 at 13:15

1 Answers1

11

OK, so I turned to the age old solution and started to delete massive chunks of code from my project until the problem was "fixed". This helped me locate the problematic file.

I then proceeded to delete function by function until I found this little snippet: str.trim(). A quick search turned this up.

Update: Actually, I just realized something ... the problem was just a normal exception, and passing it to alert() masked the details. If you let such exceptions go to the top, then whatever browser you use will display useful line information. So, the next time it happens to me, I'm going to look for a way to make the exceptions fly high outside of the top level function. The catch wasn't in my code, it was jQuery, so I'm still not quite sure how to do it.

Community
  • 1
  • 1
ripper234
  • 202,011
  • 255
  • 600
  • 878