定义Javascript对象时IE8错误? [英] IE8 errors when defining a Javascript object?
问题描述
我知道IE8很痛苦,但我从未见过它给我带来这样的麻烦。我要做的就是定义一个Javascript对象,它会导致错误,阻止所有脚本在页面上工作。
I knew IE8 was a pain, but I have never seen it give me such trouble. All I am trying to do is define a Javascript object and it causes an error, stopping all scripting from working on the page.
错误是预期的标识符,字符串或数字并表示问题发生在我定义下面的属性类的地方。我看过无数的脚本以这种方式定义对象,那么为什么IE8会呕吐呢?
The error is "Expected identifier, string or number" and indicates that the issue happens where I define the property "class" below. I have seen countless scripts define objects this way, so why does IE8 vomit on this?
我将有问题的代码隔离开来。将其置于HTML页面的头部并在IE8中运行将导致我看到的问题。
I isolated the offending code to this. Placing this in the head of an HTML page by itself and running it in IE8 will cause the issue I am seeing.
<script type="text/javascript" language="javascript">
var atts = {class: "trigger"};
</script>
推荐答案
通过用引号括起来定义使用适当的数据类型,class
Define using appropriate data type by enclosing in quotes, "class"
这篇关于定义Javascript对象时IE8错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!