Javascript vs. IE8 – 预期的标识符,字符串或数字

不,这不是一个额外的逗号。

这是给我问题的剪辑。

$(document).ready(function(){ $("div#slider").easySlider({ auto: false, continuous: true, nextId: "nextBtn", prevId: "prevBtn" }); $("div#slider-banner").easySlider({ auto: true, continuous: true, controlsShow: false }); // <---------------------------------- Line 14 $("div#slider-photos").easySlider({ auto: true, continuous: true, controlsShow: false }); $("#marquee").marquee({ scrollSpeed: 25, pauseSpeed: 2000, showSpeed: 850 }); }); 

错误详情

 User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET CLR 1.1.4322; Tablet PC 2.0; OfficeLiveConnector.1.3; OfficeLivePatch.0.0) Timestamp: Wed, 6 Apr 2011 15:20:42 UTC Message: Expected identifier, string or number Line: 14 Char: 5 Code: 0 

这是随机IE8安装,任何想法?

尝试将所有对象属性放在(双)引号中,如下所示:

 $("div#slider").easySlider({ 'auto': false, 'continuous': true, 'nextId': "nextBtn", 'prevId': "prevBtn" }); 

在2015年。如果您仍然关心IE8的兼容性(或多或少),我的问题只是在实时服务器上显示,但在localhost上没有发生(如图)。 并且,它以这样的方式触发了IE8错误,它进入了IE7兼容性视图,这也像Quirks模式一样糟糕。

在任何情况下,上述任何提示都无法解决问题,并且列出一些参数/选项后问题是一个尾随逗号。

例如:

 $(document).ready(function(){ $('#selector').func({ rules: { parameter1: { option1: true, option2: 1, option3: 5 } }, // <- this trailing comma is fatal to IE8 }); }); 

我有敲门类attr绑定的类似问题。 碰巧类属性必须用’class’这样的引号括起来。