randomguy
randomguy

Reputation: 12252

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 token ILLEGAL with the newest Google Chrome.

Upvotes: 1

Views: 96

Answers (3)

Farzin Zaker
Farzin Zaker

Reputation: 3606

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

Upvotes: 0

Erik
Erik

Reputation: 4105

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

Upvotes: 1

Felix Kling
Felix Kling

Reputation: 817030

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.

Upvotes: 5

Related Questions