0
我的index.html和page.html中PhoneGap的處理後退按鈕不關閉應用程序
的index.html有一個錨page.html中
我會在後退按鈕按下,並詢問用戶是否他真的想回去的index.html
這是我的代碼:
的index.html
<!DOCTYPE HTML>
<html>
<head>
<title>First App</title>
<script src="cordova-2.6.0.js"></script>
<script>
function onLoad(){
document.addEventListener("deviceready",onDeviceReady, true);
}
function onDeviceReady(){
navigator.notification.alert("PhoneGap is working!!");
}
</script>
</head>
<body onload="onLoad();">
<h1>Welcome to PhoneGap</h1>
<h2>Edit assets/www/index.html</h2>
<a href="page.html">Go to page</a>
</body>
</html>
page.html中
<!DOCTYPE HTML>
<html>
<head>
<title>First App</title>
<script src="cordova-2.6.0.js"></script>
<script>
function onLoad(){
document.addEventListener("deviceready",onDeviceReady, true);
document.addEventListener("backbutton", onBackKeyDown, false);
}
function onDeviceReady(){
navigator.notification.alert("PhoneGap is working!!");
}
function onBackKeyDown(e) {
navigator.notification.alert("PhoneGap back is working!!");
}
</script>
</head>
<body onload="onLoad();">
<h1>Welcome to PhoneGap Page</h1>
<h2>Edit assets/www/page.html</h2>
</body>
</html>
的問題是後退按鈕按下沒有被處理,但科爾多瓦正確加載,因爲我有警告框顯示。
我做錯了什麼?
我有一個三星谷歌Nexus採用Android 4.2.2
非常感謝。