我怎么在Android中使用Jquerymobile,PhoneGap的禁用手机的返回按钮按钮、我怎么、手机、Jquerymobile

2023-09-07 23:57:20 作者:佐掱の恛憶

可能有人请告诉我如何禁用Android的后退按钮(这是所有Android手机中的后退按钮)。

我使用jQuery Mobile的使用PhoneGap的。我发现这个网上的科尔多瓦文档中,但这并不为我工作。后退按钮事件甚至没有注册。

 函数的onLoad(){    的console.log(**** INSIDE ONLOAD功能*****);    document.addEventListener(后退按钮,onBackKeyDown,FALSE);}//处理后退按钮功能onBackKeyDown(){    // pressing后退按钮不打印此消息。    的console.log(**************** INSIDE返回按钮*************);} 

解决方案

我用 backKeyDown 和它的作品对我来说:

 函数onDeviceReady(){        document.addEventListener(后退按钮,backKeyDown,真正的);        的console.log(PhoneGap的是准备好了);    }    功能backKeyDown(){        navigator.app.exitApp(); //要退出应用程序!    } 

确保 PhoneGap的准备

更新::您可以将处理程序空的禁用

使用jQuery Mobile实现新闻浏览器 3

Could someone please tell me how to disable Android's back button (That is the back-button found on all Android phones).

I am using Jquery mobile with PhoneGap. I find this online in the Cordova documentation, but this does not work for me. Back button event is not even registering.

function onLoad() {
    console.log("**** INSIDE ONLOAD FUNCTION *****");
    document.addEventListener("backbutton", onBackKeyDown, false);   
}

// Handle the back button
function onBackKeyDown() {

    // Pressing the back button does not print this message.
    console.log("**************** INSIDE BACK BUTTON *************");
}

解决方案

I used backKeyDown and it works for me :

function onDeviceReady() {
        document.addEventListener("backbutton", backKeyDown, true);
        console.log("PhoneGap is ready");
    }

    function backKeyDown() {
        navigator.app.exitApp(); // To exit the app!
    }

make sure that PhoneGap is ready!

Update: You can leave the handler empty to disable it