我在 jQuery 的 Chrome 和 Mozilla 中遇到了非常奇怪的行为。我的函数出现了非常普遍Unexpected token ILLEGAL的错误。document.ready
在玩签名板示例时,我在自己的页面上进行了尝试。它不适用于 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>