Mr eel

Internet Explorer - Something to look out for when coding JS

Internet Explorer doesn’t just have a shit box model, it also has a terrible javascript engine. Inevitably my DOM-compliant javascript code — which works beautifully in Firefox — will explode when I try to run it in Internet Exploder.

The debugging text is useless. The actual error text is vague i.e. “not implemented”. What’s not implemented? It never tells me. That wouldn’t be quite as bad, but it mis-reports the line the error is occurring on, so even an educated guess is difficult.

Trial and error(s) is the only way to pin the bastard down.

Anyway, all this complaining was prompted by one particular problem I had to debug today. IE has a global variable called parent. I was using this variable to store a reference to a DOM node’s parent (but of course!). I could care less what IE was using the variable for, I just wanted it! The problem was that I was trying to assign a value to the variable without declaring it. IE didn’t like that so much. So I declared the variable using var, squashing the original reference and the problem went away.

Grrrrrrrrr.

Posted on November 22nd, 2005 | There are 1 comment

Comments

Duncan Beevers on August 7, 2006

Hopefully you won’t have to hunt too many more of these bugs, but IE does have some debugging options.

http://blogs.msdn.com/ie/archive/2004/10/26/247912.aspx

Obviously, Firebug is much better, but it’s nice to be able to get in there and dig around when you have to.

Add a comment

All contents © 2005—2007 Luke Matthew Sutton