How to clear inbetween webpages while moving from nth page to 1st page in HTML or JS

127 views Asked by At

I'm new to web programming. I'm working on PhoneGap android app. In that create a page from that i moving to many pages by swiping right side.

Problem: Suppose if i moved to nth page from that if i press home button, i need to clear inbetween page history and home page should get to shown.

How to do that using html or JS?

EDIT:

    function onDeviceReady() {
    document.addEventListener("backbutton", function(e) {
        e.preventDefault();
        navigator.app.exitApp();
    }, true);
}
1

There are 1 answers

4
kangoroo On

ok, experimental but can be a solution for you

$(document).on("pagebeforechange", function( e, data ) {
if ( typeof data.toPage === "object" ) {


                    var text = data.toPage.attr('id');

                    if(text =="your page name") {

                        $.mobile.changePage("#homepage", { transition: "none", reverse : true } );
                        e.preventDefault();

                    }
}

basically you are saying, hey, if I am coming from "your page name" don't do the default "going back" but go to home page