开发者

Why is this piece of Javascript giving a parse error?

<script type="text/javascript"> var flashvars = { file: ’foo’, autostart: ’true’ };
</script>

Throws Uncaught SyntaxError: Unexpected to开发者_开发技巧ken ILLEGAL with the newest Google Chrome.


Probably because you don't use proper quotation marks. You use instead of ' or ".

<script type="text/javascript"> 
    var flashvars = {file: 'foo', autostart: true };
</script>

Two more things:

  • Don't escape the quotes of the type attribute.
  • true does not have to be in quotes.


You are using the wrong kind of apostroph. You write ’foo’ but it must be 'foo'


<script type="text/javascript"> 
var flashvars = { 'file': 'foo', 'autostart': true }; 
</script> 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜