I'm trying to disable back button press so the app does not close as my app is a single page app..
i read that you need to wait for deviceready event, and if i look at the console im receiving that event. (BUT from another location i suspect its hidden in the templated and cant find out how to apply my functions to that) Received Event: deviceready
problem is that im just not receiving anything and my app just closes when the i press the back button. and i think im receiving the deviceready from somewhere else build in by adobe in the template i used for my app..
so none of the functions are getting fired thats why i tend to believe i need to place this somewhere else
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
alert('gege');
}
// device APIs are available
//
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
alert('gege');
}
// Handle the back button
//
function onBackKeyDown() {
alert('backbuttonpressed');
}
</script>
Try
document.addEventListener("deviceready", onDeviceReady, false);
document.addEventListener("backbutton", onBackKeyDown, false);
app.initialize();
function onDeviceReady(){
}
function onBackKeyDown(event) {
event.preventDefault();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.