Using history.js , the following function βlistensβ for changes in the url string and calls the function to load the corresponding page:
History.Adapter.bind(window,'statechange',function(){ var State = History.getState(); page(State.url); }); function page(url) {
Now, when you want to change the page, you call:
History.pushState({state:X}, "Page Title", "Page Url");
This will update the browser url string and automatically call up the page (State.url) for the new URL; and all browser functions, such as the forward / back button, bookmarks, etc., should work.
source share