The history.js library makes it quite easy to do such things using the HTML5 history API (with a hash reserve for browsers that do not have an API).
You can do something like:
function shownext(){ $(this).next('div').fadeIn(500); // Push state with next page number. } function showprev(){ $(this).prev('div').fadeIn(500, backup); // Push state with previous page number. } History.Adapter.bind(window,'statechange',function(){ var State = History.getState(); goToPage(State.data.page); } function goToPage(page) { // Go to page. }
The documentation and demos for the library are very useful.
source share