我正在尝试使用以下代码关闭我的 Phonegap Android 应用程序:
document.addEventListener("backbutton", function () {
if ($('.screenshot').is(":visible")) {
if (confirm('Afsluiten?')){
setTimeout( function() { navigator.app.exitApp(); });
}
else {
'';
}
}
else {
$(".items , .screenshot").show();
$(".content , .openbrowser , .html5vid , .introtekst_gal" ).hide();
$(".terug").hide();
}
}, true);
它只工作一次:按后退按钮然后按“确定”关闭应用程序,如预期的那样。
但是当我这样做时,应用程序不再关闭:
- 按后退按钮(弹出显示)
- 按“取消”(弹出窗口消失)
- 按后退按钮(弹出显示)
- 按“确定”(弹出窗口消失,应用应该关闭,但没有关闭)
我做错了什么?
最佳答案
你可以试试这个代码:
document.addEventListener("backbutton", function () {
navigator.notification.confirm(
'Do you want to quit',
onConfirmQuit,
'QUIT TITLE',
'OK,Cancel'
);
}, true);
function onConfirmQuit(button){
if(button == "1"){
navigator.app.exitApp();
}
}
关于jquery - 关闭 Android 应用 Jquery - Phonegap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10123005/