In my PhoneGap android app, in my Index.html page in OnDeviceReady() method I have added the following function for backbutton event listener.
document.addEventListener("backbutton", function(e) {
var sPath=window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
if(sPage == "index.html"){
e.preventDefault();
// My action
return false;
} else {
return true;
}
}, false);
Problem Facing:
In my HomePage(Index.html) its working fine. If i press back button it gets closed.
But in all other pages (Page1.html,Page2.html,Page3.html,Page4.html) i havn't created backbutton event listener but nothing happens when i press back key.