2016-07-22 72 views
1

我有一個問題,後退按鈕上的科爾多瓦事件沒有執行任何警告(「」)。科爾多瓦的後扣不起作用

有趣的是,代碼看起來很完美,我甚至沒有忘記引入cordova.js我唯一能想到的就是有必要洗一個插件,因爲我沒有任何建立。

我的代碼看起來像這樣:

<head> 
    <meta charset="utf-8" /> 
    <meta name="format-detection" content="telephone=no" /> 
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" /> 
    <link rel="stylesheet" href="css/phonon.css" /> 
    <style> 
     .uvitani { 
      font-size: 250%; 
      margin: 0; 
      color: white; 
      position: absolute; 
      top: 40%; 
      left: 50%; 
      margin-right: -50%; 
      transform: translate(-50%, -50%) 
     } 

     .tlacitko { 
      margin: 0; 
      color: #0084e7; 
      background-color: white; 
      position: absolute; 
      bottom: 0; 
      left: 50%; 
      margin-right: -50%; 
      transform: translate(-50%, -50%) 
     } 
    </style> 
</head> 
<script type="text/javascript" charset="utf-8"> 
    function barva() { 
     alert(cordova.platformId); 
     if (cordova.platformId == 'android') { 
      StatusBar.backgroundColorByHexString("#0065b3"); 
     } 
     document.addEventListener("backbutton", onBackKeyDown, false); 

     function onBackKeyDown() { 
      alert("Back"); 
     } 
    } 
</script> 

<body style="background-color: #0084e7;" onload="barva();"> 
    <center> 
     <p class="uvitani">Vítejte v aplikaci ISAS</p> 
     <button class="btn tlacitko" onclick='document.location="styl.html";'>Pokračovat</button> 
    </center> 
    <script type="text/javascript" charset="utf-8" src="cordova.js"></script> 
    <script src="js/phonon-core.js"></script> 
    <script src="js/components/forms.js"></script> 
    <script src="js/components/preloaders.js"></script> 
    <script src="js/components/dialogs.js"></script> 
</body> 

</html> 
+0

將錯誤添加到您的問題 – Zoe

+0

請在alert(「back」)中傳遞一些字符。 –

+0

警報未啓動 – Lukas0025

回答

0

請警告框的推移,一些字符,並返回到假,

 function barva() { 
      alert(cordova.platformId); 
      document.addEventListener("deviceready", onDeviceReady, false); 
     } 

     function onDeviceReady(){ 
     if (cordova.platformId == 'android') { 
       StatusBar.backgroundColorByHexString("#0065b3"); 
      } 
      document.addEventListener("backbutton", onBackKeyDown, false); 
     } 
     function onBackKeyDown(){ 
      alert('back'); 
      return false; 
     } 

更多的幫助檢查here

請檢查你的插件,

您需要添加以下的插件在您的項目

cordova plugin add org.apache.cordova.statusbar 

希望此舉能幫助你!

+0

請評論一段時間的代碼檢查解決方案 –

0

這足以修復狀態欄顏色(I/chromium(18807): [INFO:CONSOLE(37)] "Uncaught ReferenceError: StatusBar is not defined", source: file:///android_asset/www/login.html (37)),現在它可以工作。

<script type="text/javascript" charset="utf-8"> 
    function barva() { 
     document.addEventListener("deviceready", onDeviceReady, false); 
    } 
    function onDeviceReady() { 
     if (cordova.platformId == 'android') { 
      StatusBar.backgroundColorByHexString("#0065b3"); 
     } 
     document.addEventListener("backbutton", onBackKeyDown, false); 
    } 
    function onBackKeyDown() { 
     alert("back"); 
     return false; 
    } 
</script> 

謝謝你的幫忙。