Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the general solution to "typeerror object doesn't support this property or method" on IE8?

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?

like image 483
ripper234 Avatar asked Mar 09 '12 08:03

ripper234


1 Answers

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.

like image 100
ripper234 Avatar answered Nov 04 '22 21:11

ripper234