开发者

My IE9 is fine with trailing comma, user's IE9 is not; why?

I have a web app with a JavaScript file using code like the following:

var foo = {a:'b',c:'d',e:'f',};

On my computer, IE9 (9.0.8112.16421) works correctly; the JavaScript is parsed and executed as on Chrome/FF/Safari. Another user claims to have the same version of IE, yet gets this error in the Developer Tools Console:

SCRIPT1028: Expected identifier, string or number 
blob.js?modified=1304026278, line 524 character 136

开发者_运维百科Column 136 is the trailing comma/closing brace for the object literal.

I've 'fixed' the code so the user should have no more problems, but I'm wondering:

What could make the same version of IE on two different computers treat the JavaScript differently?


One of the reasons may be that user has pressed the "Compatibility View" button. The trailing comma causes syntax error in IE7 document mode.


Its most likely due to a browser setting suppressing the error on your browser.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜