问题
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