Cryptic javascript error in Internet Explorer 78: ':' expected - Stack Overflow

On one of our sites we get a very cryptic JS error from the Internet Explorer. In the console it says:&

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 badges
Add a ment  | 

4 Answers 4

Reset to default 4

That'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:

  1. Object literal e.g. var obj = {foo: bar};
  2. Ternary operator e.g. var str = (i === 0 ? "yes" : "no");
  3. 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 ':'

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744230484a4564221.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信