My page is very basic
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<h1>Title</h1>
<canvas id="can"></canvas>
<video autoplay id="vid" style="cursor:pointer"></video><br>
<script type="application/javascript;version=1.7" src="8bit.js"></script>
</body>
</html>
It loads the JavaScript Firefox, but does not in Chrome.
If I copy and paste the contents of the JavaScript file into the console in Chrome, then it runs fine.
Why doesn't it load from the script tag in Chrome?
Essence from the MDN about let
keyword:
The keyword
let
is supported in Chrome only for testing purposes only in the Console and not in the normal flow. Chrome doesn't supportlet
but Firefox does.
Replace the following:
<script type="application/javascript;version=1.7" src="8bit.js"></script>
With:
<script type="text/javascript" src="8bit.js"></script>
Chrome makes a strict decision on type
attribute. So please use that carefully. Only for Firefox, this is valid:
Only available to code blocks in HTML wrapped in a
<script type="application/javascript;version=1.7">
block (or higher version). Beware, however, that as this is a non-standard feature, this will most likely break support for other browsers. XUL script tags have access to these features without needing this special block.
Workaround for Chrome:
To enable these special keywords, add the following code on the top of the script block:
"use strict";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With