另一个IE'Object expected'错误,没有任何信息 [英] Yet another IE 'Object expected' error with no information
问题描述
嘿,我一直在用我在这个网站上遇到的这个错误拉我的头发。
我在第1行遇到可怕的对象预期
错误,仅在IE6和IE7中出现了字符21。我只是想知道是否有人知道这可能与什么有关。我知道整个尾部逗号问题,所以我非常小心。
任何想法都将非常感谢。谢谢。
我们在IE中修复了对象预期错误,所以要在您的评论中回答这个问题:
问题出在您的HTML中。
:
< div class ='tab'id ='introduction'>
< h2 id ='introduction'>介绍< / h2>
< / div>
< div class ='body'id ='introduction'style ='display:block'>
问题在于你要用 id ='介绍来指定两个元素'
。
由于各种原因,您不应这样做:
第37行,第27列:重复的ID介绍。
第36行,第39列:ID介绍的第一次出现在这里。
它破坏了IE7中的标签。 还有其他一些原因,但它们在这里并不重要。
如果我将其更改为(例如):
< div class ='tab'id ='introduction'>
< h2 id ='introduction'>介绍< / h2>
< / div>
< div class ='introduction body'style ='display:block'>
(请记住以相同的方式更改所有四个实例)
如果我将这个JS改为这个(例如),它可以工作:
Spark('。'+ currentTab)
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.
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)
这篇关于另一个IE'Object expected'错误,没有任何信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!