1

我正在开发 android phonegap 应用程序。我编写了一些代码来禁用后退按钮。

function onLoad(){
    document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
document.addEventListener("backbutton", backKeyDown, true);
console.log("device is ready");
}
function backKeyDown() {
try{
    /document.body.style.cursor = 'none';
    if(!(($('#LoadingImage').is(':visible') )){
        /*document.body.style.cursor = 'none';*/
        jConfirm('Are you sure you want to exit?', 'Confirm', function(r) {        
            if (r == true) {
            localStorage.clear();
                navigator.app.exitApp();
            }      
        });  
    }
    else{

    }

}
catch(err){
    alert(err.message);
}
finally{

}
}

其中 loading Image 是一个显示加载符号的 div。

 <div id="LoadingImage" style="display:none">
            <div id="floatingCirclesG">
                <div class="f_circleG" id="frotateG_01">
                </div>
                <div class="f_circleG" id="frotateG_02">
                </div>
                <div class="f_circleG" id="frotateG_03">
                </div>
                <div class="f_circleG" id="frotateG_04">
                </div>
                <div class="f_circleG" id="frotateG_05">
                </div>
                <div class="f_circleG" id="frotateG_06">
                </div>
                <div class="f_circleG" id="frotateG_07">
                </div>
                <div class="f_circleG" id="frotateG_08">
                </div>
            </div>
        </div>

我的问题是在加载 div 节目时,我单击设备后退按钮应用程序在 Galaxy ace 2.3 版中崩溃,但它在 Galaxy s2 4.0 版中运行良好。请帮我解决这个问题。提前致谢!

4

0 回答 0