2016-03-26 12 views
0

phonegapをビルドしてAndroidの電話機でテストするときに問題があります。javascriptが実行されません。Phonegap - Javascriptが動作しない

私は、単純なconfig.xmlファイルを持っている、と私のindex.htmlの頭のプレビューがあります:

<!doctype html> 
<html lang="fr"> 
<head> 
<meta charset="utf-8"> 
<title>My app</title> 

<script type="text/javascript" charset="utf-8" src="cordova.js"></script> 
<script type="text/javascript" src = "phonegap.js" > </script> 
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, minimum-scale=1, user-scalable=yes"> 
<link href='https://fonts.googleapis.com/css?family=Quicksand' rel='stylesheet' type='text/css'> 
<link rel="stylesheet" href="Mobile_style.css"><link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript" src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"> 
<link href='https://fonts.googleapis.com/css?family=Quicksand:700' rel='stylesheet' type='text/css'> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
<script type="text/javascript" charset="utf-8" src="cordova.js"></script> 
<script type="text/javascript" src = "phonegap.js" > </script> 
<script type="text/javascript" charset="utf-8"> 

function onBodyLoad() 
     {      
      document.addEventListener("deviceready", onDeviceReady, false); 
     } 


     function onDeviceReady() 
     { 
      // do your thing! 
     } 
    </script> 

    <script type="text/javascript"> 
    window.onload = function() 
    { 

     MY JS CODE 

} 
</script> 
</head> 
<body onload="onBodyLoad()"> 

     MY HTML 

</body> 

私は2つのHTMLファイル、index.htmlをとgame.htmlを持って、私が持っていますゲームの頭の中で同じリンクやスクリプト。

私は自分のコードを入れようとしましたが、動作していません。

私は数時間の検索をしましたが、問題を解決できます。

ありがとうございました!

+0

あなたは 'cordova.js'と' phonegap.js'宣言を2回繰り返しています。最後の2を削除し、残りの1つを削除します。あなたのページに宣言されているjQueryのバージョンは1つだけで、それに合わせてjQueryUIを追加することもできます。 –

+0

ありがとう、私はどこに私のjsコードを置く必要がありますか? – Sanalol

答えて

1

jqueryのバージョンは1つだけ含める必要があります。また、cordova.jsとphonegap.jsの両方を必要とせず、1つのスクリプトを選択します。

あなたのコードは、はるかにきれいに見えることがあります。

<!doctype html> 
<html lang="fr"> 
<head> 
    <meta charset="utf-8"> 
    <title>My app</title> 


    <meta name="viewport" 
      content="width=device-width, initial-scale=1.0, maximum-scale=1, minimum-scale=1, user-scalable=yes"> 

    <link rel="stylesheet" href="Mobile_style.css"> 
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"> 
    <link href='https://fonts.googleapis.com/css?family=Quicksand:700' rel='stylesheet' type='text/css'> 

    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 
    <script type="text/javascript" src="phonegap.js"></script> 

    <script type="text/javascript" charset="utf-8"> 

     document.addEventListener("deviceready", onDeviceReady, false); 

     function onDeviceReady() { 
      alert("Device is ready"); 
     } 

    </script> 
</head> 
<body> 

    MY HTML 

</body> 
</html> 
+0

他のスクリプト宣言を含め、冗長な宣言を削除して、OPが私たちが話していることを知るようにする必要があります。 –

+0

答えに感謝しますが、私は "払い戻し"が何であるか分かりません。どこで私のjsコードを置く必要がありますか? – Sanalol

+0

@Sanalol上記の例を見てください。 「冗長」な「

関連する問題