I tried to implement the back button functionality in my wp8 cordova application , which on pressing the hardware back button on device should navigate to the previous page of the app .
What i have done
function onLoad() {
document.addEventListener("deviceready", init, false);
document.addEventListener("resume", onResume, false);
document.addEventListener("backbutton", onBackKeyDown, false);
}
function init() {
//some code
}
function onResume() {
//some code
}
function onBackKeyDown() {
window.history.back();
return false;
}
I also tried replacing the "window.history.back();" with "navigator.app.backHistory();" which also doesnot seems to work
Then i tried putting the code in try catch block
try
{
navigator.app.backHistory();
//window.history.back();
}
catch (e)
{
console.log("exception: " + e.message);
}
which also seems to fail .Whatever I do the app seems to exit out of the app rather than moving backward and the funny thing is when i try this in the IE console it seems to work perfectly
Please help with this guys
Thanks in advance