Javascript DataTables jQuery插件-Firefox声明;“非法字符”;
有这样的东西:Javascript DataTables jQuery插件-Firefox声明;“非法字符”;,javascript,jquery,firefox,datatables,cdn,Javascript,Jquery,Firefox,Datatables,Cdn,有这样的东西: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="https://code.jquer
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<script>
$(document).ready(function() {
$("#myTable").dataTable({
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"iDisplayLength": 25,
"order": []
});
});
</script>
<style>
th,
td {
white-space: nowrap
}
TD+TD+TD+TD+TD+TD {
color: white
}
</style>
</head>
<body>
<table id="myTable" class="display" cellspacing="0" width="100%"> .... </table>
</body>
</html>
$(文档).ready(函数(){
$(“#myTable”).dataTable({
“长度菜单”:[[10,25,50,-1],[10,25,50,“全部”],
“iDisplayLength”:25,
“命令”:[]
});
});
th,
运输署{
空白:nowrap
}
TD+TD+TD+TD+TD+TD+TD+TD{
颜色:白色
}
....
这在internetexplorer11
中运行良好Firefox 52
不会加载DataTables插件,并在从CDN加载的jquery.DataTables.min.js
的第一个字符上声明语法错误:非法字符
。
还尝试保存js文件并在本地加载,但仍然相同。
这是怎么回事
谢谢你的帮助
编辑:
因此,我下载了DataTables CSS和JS文件,并使用编码UTF-8和BOM
重新保存它们。它们以前保存为UTF-8
(无BOM)。现在它开始工作了。这是Firefox中的一个bug吗?如何避免此问题?解决此问题的方法是:
<script type="text/javascript" src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" charset="utf-8">