Object Expected Error in IE7 -> WTF?

I had a problem with List Central’s javascript that would only appear in IE7 for me. My code ran happily, without even a warning in Firefox, Safari, and even IE8. This combined with the cryptic nature of Internet Explorer’s error messages, I was at quite a loss tracking this one down. I started searching on “Object Expected Error in IE7″, which finally led me to a solution, a solution I wasn’t expecting!

This forum post, particularly Happy Noodle Boy’s suggestion led me to go through all of my javascript looking for trailing commas. I found one. After removing the one tailing comma, like the one following the 3 here:

var obj = {
   prop1: 1,
   prop2: 2,
   prop3: 3,
}

IE7 quit its complaining, and executed my Javascript.

If you are having a hard time tracking down the source of an painful Object Expected error in Internet Explorer, try looking for trailing commas.

Posted in Javascript, Web Development. Tagged with , , , .

One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. ,..] blog.listcentral.me is one another useful source of information on this topic,..]

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.