我正在尝试使用以下代码关闭我的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);
Run Code Online (Sandbox Code Playgroud)
它工作一次:按下后退按钮然后"确定"按预期关闭应用程序.
但是,当我这样做时,应用程序不再关闭:
我究竟做错了什么?