backbutton
The event fires when the user presses the back button. To override the default back-button behavior, register an event listener for the backbutton event. It is no longer necessary to call any other method to override the back-button behavior.
Quick Example
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
// Handle the back button
}
Windows Quirks
Throw an error in a backbutton callback to force the default behavior, which is an app exit:
document.addEventListener('backbutton', function (evt) {
if (cordova.platformId !== 'windows') {
return;
}
if (window.location.href !== firstPageUrl) {
window.history.back();
} else {
throw new Error('Exit'); // This will suspend the app
}
}, false);
Please login to continue.