admin管理员组文章数量:1401122
On one of our sites we get a very cryptic JS error from the Internet Explorer. In the console it says:
':' expected
javascript:false, Line 1 Character 24
When I click on the error to see which JS is causing the error a message pops up: "For this error no source is available". So I really can't tell you where this es from.
This is extremely cryptic to me. Does anyone know what could cause this?
On one of our sites we get a very cryptic JS error from the Internet Explorer. In the console it says:
':' expected
javascript:false, Line 1 Character 24
When I click on the error to see which JS is causing the error a message pops up: "For this error no source is available". So I really can't tell you where this es from.
This is extremely cryptic to me. Does anyone know what could cause this?
Share Improve this question asked Jan 24, 2012 at 16:55 Florian RachorFlorian Rachor 1,57415 silver badges31 bronze badges4 Answers
Reset to default 4That's probably from an incorrect object literal. For example:
var foo = {bar};
... gives exactly the error you describe in IE 7 and 8.
At a guess, a malformed object literal. Something like { foo bar }
which should be { foo: bar }
.
The places it would expect a colon are:
- Object literal e.g.
var obj = {foo: bar};
- Ternary operator e.g.
var str = (i === 0 ? "yes" : "no");
- Switch case statement
That could help you narrow it down. However, I suspect since you seem to indicate that the problem is only in IE that it is due to automatic semicolon insertion. For that I would run the scripts through JSLint to help find and correct ambiguities.
I can only really think of one place a colon is used in Javascript, and that's ternary operators. (Edit: Yes, there are object literals too, thanks other posters)
So is it possible you have a line that looks like it should be a Ternary op, but is missing the colon? This hypothesis is somewhat backed up by the talk in the error message of "false" as the part after the colon represents the false action.
Kind of got the same error with this jsfiddle: http://jsfiddle/CNTY8/
Expected ':'
本文标签: Cryptic javascript error in Internet Explorer 78 3939 expectedStack Overflow
版权声明:本文标题:Cryptic javascript error in Internet Explorer 78: ':' expected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744230484a2596305.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论