Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
118
rated 0 times [  121] [ 3]  / answers: 1 / hits: 26293  / 9 Years ago, mon, august 17, 2015, 12:00:00

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?


More From » html

 Answers
62

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 support let 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; 

[#65390] Friday, August 14, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
victorr

Total Points: 193
Total Questions: 86
Total Answers: 105

Location: Pitcairn Islands
Member since Thu, Jun 24, 2021
3 Years ago
victorr questions
Fri, Nov 13, 20, 00:00, 4 Years ago
Sat, Jul 25, 20, 00:00, 4 Years ago
Thu, Jun 11, 20, 00:00, 4 Years ago
;