应用程序在点击设备后退按钮时崩溃了?

时间:2013-04-15 10:11:07

标签: javascript android jquery cordova

我正在开发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中工作正常。请帮我解决这个问题。 提前谢谢!

0 个答案:

没有答案
相关问题