How to get the list of History Pages in Jquery Mobile

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.

So if you want to go back to previous page with javascript you can do the following

Similarly you can you can traverse to any back page by reducing the history index as below

Also you can navigate to next page using any positive history index

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

$.mobile.urlHistory.stack

I think all other methods are self explanatory. Please try and let me know if you have any comments.

Note:

  • I assume that, the readers are good in Jquery and Jquery mobile