I'm trying to use let
and yield
in Firefox. I am testing in both versions 18 and 21 (Nightly) and getting the same results.
Here's my really simple test script:
<html>
<head>
<title>test</title>
<script type="text/javascript">
'use strict';
function a() {
yield 5;
}
</script>
</head>
<body></body>
</html>
I get this error:
Similarly when I do a simple test with let
I get "let is a reserved identifier", which is really frustrating because let
has supposedly existed in Firefox since version 2!
Strangely, if I execute the same code in Firebug it works!
I have tried various other strings in the type
and language
attributes of the script
tag but have not found a magic one that works.
What's going on? How do I get this stuff working with a script tag?
Edit
Hmm, I see, so you must specify the version number. I had tried this, but for my original more plicated script which used web workers. Apparently using version=1.7
on a script which includes a web worker which includes a script that uses let
and yield
isn't good enough -- the web worker script still breaks... Then I tried reducing to simplest case but apparently didn't try version=1.7
in simplest case.
Thanks... Might post another question in a little bit (after searching) on how to get this working for web workers.
I'm trying to use let
and yield
in Firefox. I am testing in both versions 18 and 21 (Nightly) and getting the same results.
Here's my really simple test script:
<html>
<head>
<title>test</title>
<script type="text/javascript">
'use strict';
function a() {
yield 5;
}
</script>
</head>
<body></body>
</html>
I get this error:
Similarly when I do a simple test with let
I get "let is a reserved identifier", which is really frustrating because let
has supposedly existed in Firefox since version 2!
Strangely, if I execute the same code in Firebug it works!
I have tried various other strings in the type
and language
attributes of the script
tag but have not found a magic one that works.
What's going on? How do I get this stuff working with a script tag?
Edit
Hmm, I see, so you must specify the version number. I had tried this, but for my original more plicated script which used web workers. Apparently using version=1.7
on a script which includes a web worker which includes a script that uses let
and yield
isn't good enough -- the web worker script still breaks... Then I tried reducing to simplest case but apparently didn't try version=1.7
in simplest case.
Thanks... Might post another question in a little bit (after searching) on how to get this working for web workers.
Share Improve this question edited Jan 15, 2013 at 7:15 Nathan Wall asked Jan 15, 2013 at 5:22 Nathan WallNathan Wall 10.6k4 gold badges28 silver badges48 bronze badges1 Answer
Reset to default 19As mdn note said,
The yield keyword is only available to code blocks in HTML wrapped in a
<script type="application/javascript;version=1.7">
block (or higher version)
So changing <script type="text/javascript">
to <script type="application/javascript;version=1.7">
will make it work.