Okay, I'm making app with phonegap, and in the app I have a home button which goes to the home screen of the app, but if I click the back key after I touched the home button it goes to the page I was on before I clicked the home button, is it possible to reset the history when you navigate to the homepage? Thanks :)
Asked
Active
Viewed 2,525 times
3 Answers
4
You can't clear the history. You can listen for back button event:
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
// Handle the back button
}
and stop the propagation.

Flatlineato
- 1,066
- 15
- 32
-
how to land to a specific screen using this? – Raj Apr 22 '15 at 06:19
-
Do you want to redirect on another page when you press the back button ? try document.location = "otherpage.html" – Flatlineato Apr 22 '15 at 07:26
0
The link below recommends using location.replace(url) instead of replacing the history completely, which I'm not sure is possible anyway. However, given that this is a constrained environment (an app) wiping the history might make sense - again, if possible if you're in an app.
Alternatively, couldn't you just remove the back key and replace it with a custom one?
0
inside the event handler of the button which takes you to home:
startActivity(activityForHome); //I guess you already have this line
finish(); //now add this line

Sarwar Erfan
- 18,034
- 5
- 46
- 57