【发布时间】:2015-07-09 06:42:09
【问题描述】:
我有一个应用程序,其中单击返回按钮会提示通知窗口以确认应用程序退出。按钮“是”和“否”效果很好,但是当我点击通知窗口外部时,它会退出应用程序。
代码:
![document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", onBackKeyDown, false); //Listen to the User clicking on the back button
}
function onBackKeyDown(e) {
e.preventDefault();
navigator.notification.confirm("Are you sure you want to exit ?", onConfirm, "Confirmation", "Yes,No");
// Prompt the user with the choice
}
function onConfirm(button) {
if(button==2){//If User selected No, then we just do nothing
return;
}else{
navigator.app.exitApp();// Otherwise we quit the app.
}
}][1]
可能是什么错误?
还有什么解决方案可以在多次单击后退按钮时关闭应用程序?
【问题讨论】:
标签: android jquery ios html cordova