2014-04-15 96 views
1

我問你,因爲我卡在愚蠢的東西,我不能找出...的PhoneGap無法檢測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); 
    }); 
} 

我通過自己學習,所以我可能誤解的東西,但你可以請幫我啓發? 非常感謝您的時間。

+0

您可以在同一個地方把你的index.js其中phonegap.js和jquery.js和現在和檢查一次。 –

+0

你爲什麼每次兩次加載jquery和jquery mobile?順便說一句,應該是:'onclick =「goBack()」' –

+0

是啊有這些問題,感謝您的注意,儘管它繼續保持同樣的方式= /表現就像沒有.js –

回答

1

即使你一直在幫助我得到的JavaScript更好非常有用的,問題是多愚蠢...

在.js文件中,我使用/ *註釋了代碼,但是我沒有使用* /,因爲我認爲這並不重要,因爲我發表評論直到結束。但我錯了,我最終發現這要感謝大家的幫助。

有一個愉快的一天,並感謝

0

嘗試改變:

<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。改爲使用更輕量級的框架。

在YOUT輸入標籤
+0

'一直在嘗試,但沒有變化=/ –

+0

是否由瀏覽器識別了index.js? – IlToro

+0

不,不是,我可以點擊按鈕,但沒有任何反應 –

0

嘗試onclick="javascript:goBack();"

+0

我試過了,但不幸的是,並沒有改變一個東西=/ –

+0

你放置了你的html文件..?我的意思是在哪個文件夾? –

+0

HTML文件位於www/index.html中,而js文件位於:www/js/index.js 順便說一句,我的js文件僅由這4行組成,是否足夠?我不需要任何標題的東西? –

0

您habve包括jQuery的兩個時間:

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 

<script src="jquery-1.7.2.js"></script>