The History plugin
The popstate
event and pushState
method are part of the so-called History API that was introduced in HTML5. This means that our magic will only work if HTML5 capable browsers are used. That is, of course, not good enough. There are still a lot of people that visit your site using HTML4 capable browsers, so what do we do?
Fortunately, several plugins for jQuery exist that allow you to use the same, or a similar, API and have your code work in both types of browsers. One even has a name that will make you think of self-service restaurants again (BBQ), but I have been using the so-called jQuery history
plugin. At the time of writing, the plugin could be found at https://github.com/browserstate/history.js.