navigator.notification.alert() is not working in cordova-2.0.0.js?

99封情书 提交于 2019-12-08 12:43:23

问题


I am new to phonegap.In my application i want display alerts.For that i have used following code,

navigator.notification.alert("PhoneGap is working");

But it is not working.My total html code is,

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

       function inti()
    {
     alert("inti");
     document.addEventListener("deviceready", onDeviceReady, true);

    }
     function onDeviceReady() {
          alert("on device ready!!!!");
     navigator.notification.alert("PhoneGap is working");
    } 
    </script>
  </head>
  <body onload="inti()">
    <p id="demo">System date</p>
    <input type="button" onclick="noti()" value="Date" />
  </body>
</html>

i got Cannot call method 'alert' of undefined i got this error .can any one guide me to over come this issues. Thanks in Advance .....


回答1:


You forgot to add the cordova.js . Try to add this.

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

also add

document.addEventListener("deviceready", onDeviceReady, true); above onDeviceReady() function.




回答2:


Check your Cordova Jar file version and you have written in <script>. May it'll be different.




回答3:


navigator.notification.alert( "Yes", callBackFunctionB, // Specify a function to be called 'Heading', "OK" );



来源:https://stackoverflow.com/questions/12477772/navigator-notification-alert-is-not-working-in-cordova-2-0-0-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!