Disable Hardware back button in cordova

北城以北 提交于 2019-12-25 16:36:13

问题


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

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

Thank you


回答1:


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();
}



回答2:


Please ensure that you have correctly referenced cordova.js.

Sounds a lot like the behaviour when cordova has not been included.



来源:https://stackoverflow.com/questions/31427115/disable-hardware-back-button-in-cordova

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!