jQuery + jQuery移动端在正文中嵌入脚本标签时加载两次脚本

jQuery + jQuery mobile load script twice when script tag is emebedded in body

本文关键字:脚本 jQuery 加载 两次 标签 移动 正文      更新时间:2023-09-26

我在学习jQuery Mobile时发现了一个奇怪的行为。下面是我的测试代码。firebug显示,如果我把script标签放在body中,"test.js"被加载了两次(即使"test.js"是空的)。这是一个错误,或者我们不能把脚本标签在身体,当我们使用jquery移动?

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>test</title>
<link href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" rel="stylesheet" type="text/css" /> 
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
</head> 
<body>
<script type="text/javascript" src="/test.js"></script>
</body>
</html>

我有同样的问题,把你所有的javascript在头部。

我从来没有遇到过这样的问题,但是尝试在元素之后(但之前)添加脚本标签,或者更好的是,在pagecrecreate事件之后动态加载它。