如何设置js文件编码为utf-8
search.js文件内容:
document.write('<meta http-equiv="content-Type" content="text/html;charset=utf-8"/>');//这行不要或者放在html中
document.write("<div class='so'><select> <option value='user_id' type='int'>用户ID</option></select><span class='condition'></span><input type='button' value='搜 索' id='so_button'><input type='button' value='去除条件' id='clear_button' title='去除所有搜索条件'></div>");
再在html里引用。
在windows下测试,没有任何编码问题。放在linux+nginx中,去除所有搜索条件 这个及前面的都是乱码。
在引用此js时这样引用 :
<script src="search.js" charset="UTF-8"> </script>
在linux+nginx中,用google浏览器打开此源文件也是乱码。
用editplus打开,此文件显示为正确的utf-8编码。
最后居然是乱码。。。。。奇怪了。。。。。