Ever noticed some of the URLs in Gmail? Here’s a few samples:
https://mail.google.com/mail/#(some long string) – for a message
The most commonly used library to achieve this is Really Simple History, by Brad Neuberg and Brian Dillard. Really Simple History maintains an internal data store of the current history, so that you can implement your own back and forward buttons. Most importantly, however, it provides a simple API to handle your events, such as adding an item to history or responding to a new location request.
HistoryStorage, provide access to the library’s functionality. The project even provides complete demo files to get you started, with samples demonstrating all common usage scenarios.
Head over to the project page and check it out.