admin管理员组文章数量:1428473
I add an external JavaScript file like this:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script charset="utf-8" type="text/javascript" src="js/panel.js" ></script>
</head>
But the text stored in panel.js file is displayed like this in the HTML file:
H69�*
When I put JavaScript code in the HTML page, the text is displayed properly. But when I put JavaScript code in panel.js, it does not work.
I add an external JavaScript file like this:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script charset="utf-8" type="text/javascript" src="js/panel.js" ></script>
</head>
But the text stored in panel.js file is displayed like this in the HTML file:
H69�*
When I put JavaScript code in the HTML page, the text is displayed properly. But when I put JavaScript code in panel.js, it does not work.
Share Improve this question edited May 27, 2017 at 22:19 Badacadabra 8,5357 gold badges31 silver badges54 bronze badges asked Feb 23, 2015 at 6:45 adib16adib16 1,7073 gold badges22 silver badges36 bronze badges 3-
Is
panel.js
definitely saved as UTF-8? – Evan Knowles Commented Feb 23, 2015 at 6:46 - i use centos and do not know how to save file as utf-8 – adib16 Commented Feb 23, 2015 at 6:48
- lying about the encoding on the script tag won't help, you need to adjust the server or use ascii js files. – dandavis Commented Feb 23, 2015 at 7:35
2 Answers
Reset to default 6Then the file maybe is not properly saved as UTF-8.
$ file -i panel.js
What's the output?
If you use, for example Vi, open the file and save it with:
:w ++enc=utf-8 %
in the mac OS it is a capital -i...like this:
file -I
本文标签: htmlCharset UTF8 for external JavaScript fileStack Overflow
版权声明:本文标题:html - Charset UTF-8 for external JavaScript file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745491505a2660624.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论