我是新來phonegap.In我的申請,我想顯示alerts.For,我已經使用下面的代碼,navigator.notification.alert()在cordova-2.0.0.js中不起作用?
navigator.notification.alert("PhoneGap is working");
但它不是working.My總HTML代碼,
<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>
我得到了Cannot call method 'alert' of undefined i got this error
。任何人都可以指導我解決這個問題。在此先感謝.....
不能調用未定義的方法'alert'我得到了這個錯誤 –
你應該有一個init()方法在onload上調用,然後在init()中爲「deviceready」註冊一個監聽器,然後在onDeviceReady()警報。 –
我已經添加了你的建議。添加inti()方法onDeviceReady()不調用....我已經添加了我的完整代碼你建議請看看.... –