您可以制定解决方法来解决此问题。
您可以定义一个在按下后退按钮时触发的函数,然后验证您的用户所在的页面,并根据每个页面运行不同的操作。例如,如果他在第 3 页,那么您返回第 2 页,如果第 2 页则返回第 1 页,如果他在第 1 页,您可以关闭应用程序。
为你写了一个例子:
<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle the back button
function onBackKeyDown() {
var whichPage = functionToDetectCurrentPage(); //create a function or detect it somehow
switch(whichPage){
case "Page1":
//works only in android, iOS not quite sure, but heard it's not possible
//to do programatically
navigator.app.exitApp();
break;
case "Page2":
window.location = "Page1.html";
break;
case "Page3":
window.location = "Page2.html";
break;
case "Page4":
window.location = "Page2.html";
break;
}
}
看看 phonegap 文档。
http://docs.phonegap.com/en/1.0.0/phonegap_events_events.md.html#backbutton
让我们知道它是否对您有帮助!