navigator.notification.alert() is not working in cordova-2.0.0.js?
-
02-07-2021 - |
Question
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 .....
Solution
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.
OTHER TIPS
Check your Cordova Jar file version and you have written in <script>
. May it'll be different.
navigator.notification.alert( "Yes", callBackFunctionB, // Specify a function to be called 'Heading', "OK" );