1
我剛開始的PhoneGap,當我運行這段代碼在PhoneGap的我得到錯誤assest.html在執行此index.html文件
的index.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale = 1.0, maximum-scale=1.0, user-scalable=no" />
<script type="text/javascript" charset="utf-8" src="windows/cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
var deviceReady = false;
function init() {
document.addEventListener("deviceready", function() {
deviceReady = true;
}, false);
window.setTimeout(function() { // Always this condtion met
if (!deviceReady) {
alert("Error: Phonegap did not initialize. Demo will not run correctly.");
console.log("Error: Phonegap did not initialize. Demo will not run correctly.");
}
}, 3000);
}
function doAlert() {
var message = "This is an Alert dialog";
var title = "Attention!";
navigator.notification.alert(message, title);
}
</script>
</head>
<body onLoad="init();">
<h1>Cordova Tests</h1>
<div id="info">
<button onclick="doAlert();">
Click Me
</button>
</div>
</body>
</html>
當我運行這段代碼我是得到這個錯誤
03-19 16:37:40.998: E/Web Console(854): TypeError: Result of expression 'navigator.notification' [undefined] is not an object. at file:///android_asset/www/index.html:25
感謝在前進freinds我希望你的理解。
名是相同http://s18.postimage.org/rjwmlum89/picproject.png看到這個圖像 – QuokMoon 2013-03-20 04:46:14
但是,爲什麼 「窗口/科爾多瓦,2.0.0.js」? ??您沒有稱爲「窗口」的子文件夾。它應該只是src =「cordova-2.0.0.js」。試試這個,看看問題是否依然存在。 – GenieWanted 2013-03-20 12:11:57
感謝哥們! – QuokMoon 2013-03-20 12:21:34