admin管理员组文章数量:1289586
Screen Shot of Problem
My html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script src="scripts/vendor/require.js"></script>
</body>
</html>
The js file
var d;
That is all there is. The file used to be require.js from their main site. But I deleted everything trying to figure out what was going on. I then deleted the whole file and created a new file (with the same name). Could I have changed something with Chrome to make in interpret files this way? I can't reproduce the problem with any of my other projects. I also originally downloaded the file using jam. Really I could just start a new project folder and probably solve the problem but I am curious as to why it would do this. Maybe something stupid simple since I am new to this.
Screen Shot of Problem
My html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script src="scripts/vendor/require.js"></script>
</body>
</html>
The js file
var d;
That is all there is. The file used to be require.js from their main site. But I deleted everything trying to figure out what was going on. I then deleted the whole file and created a new file (with the same name). Could I have changed something with Chrome to make in interpret files this way? I can't reproduce the problem with any of my other projects. I also originally downloaded the file using jam. Really I could just start a new project folder and probably solve the problem but I am curious as to why it would do this. Maybe something stupid simple since I am new to this.
Share Improve this question edited Feb 16, 2013 at 2:42 user166390 asked Feb 15, 2013 at 18:52 dylntrnrdylntrnr 4415 silver badges10 bronze badges 4- 2 What encoding did you save the file as? What HTTP headers are sent with it? – SLaks Commented Feb 15, 2013 at 18:54
- I updated the screen shot to include the HTTP headers. And I just saved it again with UTF-8 just to make sure (problem is still there). Thanks for the quick response. – dylntrnr Commented Feb 15, 2013 at 19:14
- Could it be a Byte Order Mark? en.wikipedia/wiki/Byte_order_mark this is the kind of thing random unicode errors can cause – Jason Sperske Commented Feb 15, 2013 at 19:23
- @SLaks I was assuming only the js file might have the encoding error when I first read your ment, but it was the index.html file. If you submit an answer I will accept yours since you were right about the problem. – dylntrnr Commented Feb 15, 2013 at 21:17
3 Answers
Reset to default 9It was a encoding problem with my index.html file (I re-saved the file with UTF-8 encoding and the problem went away). Thanks for your help.
The problem is that the master file and the linked script file must have the same encoding, otherwise Chrome browser will not be able to load it correctly.
For example, if the html file is encoded in UTF-16 LE and the javascript file in UTF-8, then Chrome will silently assume that the javascript file is also in UTF-16 LE and fails to load it.
You can add a charset attribute to the script element to hint about encoding and in such case, Chrome will load it correctly:
<html>
<head><title>Test</title> </head>
<body>
<script type="text/javascript" charset="UTF-8" src="script.js"></script>
</body>
</html>
it's definitely not a chrome problem (look at content-length: 6
) did you try restarting your server after saving the file?
本文标签: Chrome displays JavaScript file in what appears to be ChineseStack Overflow
版权声明:本文标题:Chrome displays JavaScript file in what appears to be Chinese - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741480701a2381153.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论