[英]Phonegap can't detect index.js
我問你是因為我被困在一個我找不到的愚蠢事物上...
我是幾天前開始使用phonegap的,我的進度很好,但是今天早上,我的index.html不再在乎我的js / index.js了!
我有一個應該會發出警報的按鈕,但是當我單擊該按鈕時,什么也沒有發生。
我知道我一定有錯的地方,但是請您看看嗎?
我試圖刪除盡可能多的無用信息。 這是我的HTML代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<script src="jquery-1.7.2.js"></script>
<script src="jquery.mobile-1.1.0.js"></script>
<script src="jquery.url.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="phonegap.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile.structure-1.3.2.min.css" />
<link rel="stylesheet" href="themes/AndroidHoloDarkLight.min.css" />
</head>
<body>
<div data-role="page" data-theme="a">
<div data-role="header" data-position="inline">
<h1>My Test App</h1>
</div>
<input type="button" name="goBack" id="goBack" onclick="goBack" value="Go Back to the previous View">
</div>
</body>
</html>
這是.js:
function goBack()
{
alert("test ...");
}
/*$("#bodyPage").ready(function(){
$.mobile.allowCrossDomainPages = true;
$("#page").bind("pageshow", function(event){
var url = $.url(document.location);
var arg1 = url.param("arg1");
$("#testP").text(arg1);
});
}
我正在獨自學習,所以我可能誤會了一些東西,但是請您能幫助啟發我嗎? 非常感謝您的寶貴時間。
即使你們都在幫助我提高javascript方面非常有用,但問題還是很多。
在.js文件中,我用/ *注釋了代碼,但是我沒有使用* /,因為自從我注釋到最后,我認為這沒什么大不了。 但是我錯了,在所有人的幫助下,我終於找到了它。
祝你有美好的一天,謝謝
嘗試更改:
<input type="button" name="goBack" id="goBack" onclick="goBack" value="Go Back to the previous View">
在:
<input type="button" name="goBack" id="goBack" onclick="goBack()" value="Go Back to the previous View">
更新:文件結構有問題。
建議:不要在移動應用程序中使用jQuery Mobile。 請嘗試使用更輕量級的框架。
在您的輸入代碼中,嘗試onclick="javascript:goBack();"
您兩次包含了jquery:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="jquery-1.7.2.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.