I think I found a solution that does not require my own hack.
If you have a Phonegap / cordova application that goes from page1.html to page2.html, then a link to page1.html follows, the standard default behavior will not exit the application.
Page1 → Page 2 → Page 1 - Windows Phone will take you to page 2 instead of exiting the application. His expected behavior, but his appearance is poorly documented.
In any case, I searched around for ages, but did not find a fix that worked for me.
Lightweight friendly people see a commit that includes this fix
TL; DR, as I fixed it, use the JS value to track which page Im on, if I'm on the index page I reset the history, then I allow the buttons on the back panel to function.
IE in page1.html you could ..
var currentPage = "index";
Then they enter your app.deviceready function.
if(currentPage == "index"){ history.go(-(history.length-9999)); document.addEventListener("backbutton", handleBack, true); }else{ document.addEventListener("backbutton", handleBack, false); } function handleBack(){
The real magic here is history.go (- (history.length-9999)), which basically tells the history stack to reset. Also, the true addEventListener operator allows you to trigger the original registered event (the "Native back" button).
In any case, try and let me know if this works for you.
A source