2013-01-17 55 views
0

嗨,我已經有了一個問題,我的PhoneGap應用的PhoneGap取代JavaScript的通知PhoneGap的一個

所以這裏是我的html代碼

<body> 
<script> 
window.onload = function() { 

    document.getElementById("a_next").onclick = function(e) { 
     e = e || window.event; 
     var els = document.getElementsByTagName("input"), 
      i; 
     for (i=0; i < els.length; i++) { 
      if (!els[i].checked) { 
       alert("Not all points on your checklist, are checked!"); 
       return false; 
      } 
     } 
    }; 
}; 
</script> 

<div id="topbar"> 
<div id="title"> 
     Walk Around Check</div> 
    <div id="leftnav"> 
    <a href="index_aerosoft.html">Home</a><a href="katana_checklist_all.html">Overview</a></div> 
    <div id="rightnav"> 
     <a href="katan_checklist_beforeenginestarting.html"id="a_next">Next</a></div> 
</div> 
<div id="content"> 
     <ul class="pageitem"> 
      <li class="radiobutton"><span class="name">Electronic List - check all items</span> 
      <input name="1" type="radio" value="other" /></li> 
     </ul> 

</div> 
<div id="footer"> 
     <!-- Support iWebKit by sending us traffic; please keep this footer on your page, consider it a thank you for my work :-) --> 
    <a class="noeffect" href="katana_checklist_walaroundcheck.html">Reset Checklist</a><br /><br /> 
    <a class="noeffect" href="http://www.aerosoft.com">Aerosoft</a></div> 

</body> 

所以我想添加或用PhoneGap的替代JavaScript警告警報

document.getElementById("a_next").onclick = function(e) { 
      e = e || window.event; 
      var els = document.getElementsByTagName("input"), 
       i; 
      for (i=0; i < els.length; i++) { 
       if (!els[i].checked) { 
        alert("Not all points on your checklist, are checked!"); 
        return false; 
       } 
      } 
     }; 

,所以我會在

<head> 
function showAlert() { 
     navigator.notification.alert(
      'You are the winner!', // message 
      alertDismissed,   // callback 
      'Game Over',   // title 
      'Done'     // buttonName 
     ); 
    } 
</head> 

而讓旁邊的JavaScript警告

<body> 
<script> 
window.onload = function() { 

    document.getElementById("a_next").onclick = function(e) { 
     e = e || window.event; 
     var els = document.getElementsByTagName("input"), 
      i; 
     for (i=0; i < els.length; i++) { 
      if (!els[i].checked) { 
       alert("Not all points on your checklist, are checked!"); 
       showAlert(); 
       return false; 
      } 
     } 
    }; 
}; 
</script> 

警報呼籲這不工作,並crashs我的「所有的檢查」任何人都可以幫助孔檢查?

+0

你包含phonegap.js文件嗎?你是否等待設備就緒事件? – jcesarmobile

+0

是的......在其他html工程中,它的工作原理 –

+0

你能發佈完整的.html代碼嗎? – jcesarmobile

回答

0
window.onload = function() { 
    document.getElementById("a_next").onclick = function() { 
     document.getElementsByTagName("input").each(function() { 
      if (!jQuery(this).checked) { 
       alert("Not all points on your checklist, are checked!"); 
       showAlert(); 
       return false; 
      } 
     }); 
    }; 
}; 

Versuchs發作damit Nein德企業的其它代碼sollte達nichts blocken。

0

這裏它的工作原理:

<!DOCTYPE html> 
<html> 
    <head> 
     <title>Notification Example</title> 

     <script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script> 
     <script type="text/javascript" charset="utf-8"> 


      // Wait for Cordova to load 
      // 
      document.addEventListener("deviceready", onDeviceReady, false); 

      // Cordova is ready 
      // 
      function onDeviceReady() { 
       // Empty 
      } 

      // alert dialog dismissed 
      function alertDismissed() { 
       // do something 
      } 

      // Show a custom alertDismissed 
      // 
      function showAlert() { 
       navigator.notification.alert(
              'You are the winner!', // message 
              alertDismissed,   // callback 
              'Game Over',   // title 
              'Done'     // buttonName 
              ); 
      } 

      </script> 
    </head> 
    <body> 
     <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p> 
    </body> 
</html> 

這不作品:

<!DOCTYPE html> 
    <html> 
     <head> 
      <title>Notification Example</title> 

      <script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script> 
      <script type="text/javascript" charset="utf-8"> 


       // Wait for Cordova to load 
       // 
       document.addEventListener("deviceready", onDeviceReady, false); 

       // Cordova is ready 
       // 
       function onDeviceReady() { 
        // Empty 
       } 

       // alert dialog dismissed 
       function alertDismissed() { 
        // do something 
       } 

       // Show a custom alertDismissed 
       // 
       function showAlert() { 
        navigator.notification.alert(
               'You are the winner!', // message 
               alertDismissed,   // callback 
               'Game Over',   // title 
               'Done'     // buttonName 
               ); 
       } 

       </script> 
      <meta content="yes" name="apple-mobile-web-app-capable" /> 
      <meta content="index,follow" name="robots" /> 
      <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> 
      <link href="pics/iosIcon.png" rel="apple-touch-icon" /> 
      <meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" /> 
      <link href="css/style.css" rel="stylesheet" media="screen" type="text/css" /> 
      <script src="javascript/functions.js" type="text/javascript"></script> 
     </head> 
     <body> 
      <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p> 
     </body> 
    </html> 

任何我的其他的包括也許blockes警報^^

UPDATE

衝我看看我是否排除了function.js它的工作原理

var iWebkit;if(!iWebkit){iWebkit=window.onload=function(){function fullscreen(){var a=document.getElementsByTagName("a");for(var i=0;i<a.length;i++){if(a[i].className.match("noeffect")){}else{a[i].onclick=function(){window.location=this.getAttribute("href");return false}}}}function hideURLbar(){window.scrollTo(0,0.9)}iWebkit.init=function(){fullscreen();hideURLbar()};iWebkit.init()}}