If you are familiar with Jquery mobile this, must be common question which may come in your mind. Because most of the time you need previous page and second last page for manipulation or for navigation. For navigation you can redirect using native browser history object.
window.history.go(-1); // You will redirected to previous page
Similarly you can you can traverse to any back page by reducing the history index as below
window.history.go(-1); // You will redirected to second last page
Also you can navigate to next page using any positive history index
window.history.go(1); // You will redirected to next page(if you already used back )
But all these process can be done without knowing (maybe/may not be – at least programmatically) .
So here JQuery mobile come to picture. It tracks an maintains all the urls in the history with $.mobile.urlHistory object.
The object prototype is below
You can access the entire history stored in stack. So you access them like below
I think all other methods are self explanatory. Please try and let me know if you have any comments.
- I assume that, the readers are good in Jquery and Jquery mobile