Yet another IE 'Object expected' error with no information

Olical picture Olical · Feb 25, 2011 · Viewed 8.3k times · Source

Hey, I have been pulling my hair out with this error I am having on this site.

I am getting the dreaded Object expected error on line 1, character 21 in IE6 and IE7 only. I just wondered if anyone had any idea what this could be related to. I know about the whole trailing commas problem so I am very careful with that.

Any ideas will be much appreciated. Thanks.

Answer

thirtydot picture thirtydot · Feb 25, 2011

We fixed the "Object expected" error in IE, so to answer the question in your comments:

The problem is in your HTML.

You have this HTML, once for each tab:

<div class='tab' id='introduction'>
    <h2 id='introduction'>Introduction</h2>
</div>

<div class='body' id='introduction' style='display:block'>

The problem is that you're specifying two elements with id='introduction'.

For various reasons, you should not do that:

  • It's causing validation errors.

    Line 37, Column 27: Duplicate ID introduction.
    Line 36, Column 39: The first occurrence of ID introduction was here.

  • It's breaking your tabs in IE7.
  • There are also other reasons, but they aren't important here.

If I change it to (for example):

<div class='tab' id='introduction'>
    <h2 id='introduction'>Introduction</h2>
</div>
<div class='introduction body' style='display:block'>

(remember to change all four instances in the same way)

And if I change your JS to this (for example), it works:

// Show selected
Spark('.' + currentTab)