Reputation: 135
i am working on android phonegap, my app has 2 .html pages ,(1) index.html has multiple pages using jquery mobile, i have a link in index.html to (2)images.html, images.html is a simple html page, i want my phone's back button to navigate to index.html's multiple page having its id #page2 when i am on images.html. Any one can plz help me in getting work from (hardware) phone's back button to navigate to index.html#page2, i already have a back button code which is working absolutely fine only in index.html, but how can i make it useable to get back to index.html#page2 from images.html here is my back button code whick is working for my index.html..... // JavaScript Document
$("#page2").click(function(){
$.mobile.changePage("#page2");
});
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap loaded
function onDeviceReady() {
console.log("PhoneGap Ready!");
// waiting for button
document.addEventListener("backbutton", handleBackButton, false);
}
// handle the back button
function handleBackButton() {
console.log("Back Button Pressed!");
if($.mobile.activePage.is('#page2')){
//e.preventDefault();
navigator.app.exitApp();
}
else {
navigator.app.backHistory();
}
}
Upvotes: 0
Views: 350
Reputation: 272
Try this,
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
// Handle the back button
}
Refer this
Upvotes: -1
Reputation: 6025
Try putting $.mobile.phonegapNavigationEnabled = true
in your mobileinit
handler per http://jquerymobile.com/demos/1.2.0/docs/pages/phonegap.html instructions.
Upvotes: 0