当用户点击Android的后退按钮时,如何让应用导航2个屏幕?
以下代码:
if(document.getElementById("HomeCtrl") != undefined){
navigator.notification.confirm(messages[appLanguage].exitFromApp, function(buttonIndex){
if(buttonIndex == 1){
navigator.app.exitApp();
};
}, messages[appLanguage].appName, ["Ok","Cancel"])
this.preventDefault();
} else if(document.getElementById("BookCabController") != undefined){
angular.element(document.getElementById("BookCabController")).scope().navigationService.back();
} else if(document.getElementById("ReviewAndConfirmController") != undefined){
angular.element(document.getElementById("ReviewAndConfirmController")).scope().navigationService.back();
}
}
答案 0 :(得分:0)
这应该适合你。
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", onBackKeyDown, false );
}
function onBackKeyDown() {
history.go(-2);
}