【发布时间】:2014-07-05 03:13:16
【问题描述】:
我在 jQuery 的 Chrome 和 Mozilla 中遇到了非常奇怪的行为。我的document.ready 函数出现了非常通用的Unexpected token ILLEGAL 错误。
在使用签名板示例时,我在自己的页面上进行了尝试。它不适用于 Mozilla 和 Chrome,但适用于 IE。然后我删除了所有对 signaturepad 的引用,并在 document.ready 函数中放置了一个简单的警报,并观察到(感谢 Chrome JavaScript Errors Notifier)Unexpected token ILLEGAL error is occurring when system try to use jQuery reference。然后我从示例页面 (a.html) 中复制了所有文本,它在此页面 (b.html) 中完美运行,然后再次运行该页面。我很惊讶 a.html 页面工作正常,而 b.html 页面抛出错误。两个页面都在同一个目录中,并且具有相同的内容。
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title> </title>
<link rel="stylesheet" href="css/jquery.mobile-1.3.1.min.css">
<link href="css/jquery.signaturepad.css" rel="stylesheet">
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<script>
$(document).ready(function () {
alert('hai');
})
</script>
</body>
</html>
【问题讨论】:
-
您是否不小心粘贴了一些非打印字符? (您是否使用会显示非打印字符的编辑器?)
-
问题可能不在脚本正文中,而是在 jquery.mobile-1.3.1.min.js 中尝试使用 cdn 导入 jquery 并查看是否发生任何更改
标签: javascript jquery html google-chrome signaturepad