在Cordova中禁用硬件后退按钮 [英] Disable Hardware back button in cordova

查看:89
本文介绍了在Cordova中禁用硬件后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我不是第一个提出这个问题的人,但是先前问题的解决方案都无效.

I know I'm not the first to ask this question, but none of the solutions for the previous questions work.

我正在使用Cordova构建移动应用程序,并且我不希望用户按下硬件后退按钮,因为这可能会破坏整个业务场景.我需要从应用程序中完全禁用硬件后退按钮,以允许用户仅使用应用程序内按钮

I'm building a mobile application using Cordova, and I don't want the user to press the hardware back button because it might ruin the whole business scenario. What I need is to disable hardware back button completely from the application in order to allow the user to use only the in app buttons

谢谢

推荐答案

只需获取后退按钮响应,并防止出现默认情况.或不注意这一点.这足以停止后退按钮工作

Just fetch backbutton response and do prevent default. or do noting in that. That is more than enough to stop backbutton work

function onDeviceReady(){
    document.addEventListener("backbutton", onBackKeyDown, false);     
}
function onBackKeyDown(e) {
  e.preventDefault();
}

这篇关于在Cordova中禁用硬件后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆