Anne van Kesteren

History management for "Ajax" applications

Ever since XMLHttpRequest has been introduced the rare few who care about usability have been trying to find hacks to make sure the browser back button remains to function. This has been relatively successful through fragment identifier changes and such a technique is now frequently used. You actually want something better though. Such that you can copy the URI and give it someone, who happens to have JavaScript disabled, he can simply load the URI and get a static copy of the page you were just viewing. HTML5 introduced a new method on the object returned by the window.history attribute named pushState() which allows developers to store an object, a title, and a URI representing the current page where the URI can change the fragment, query and path part of the URI (and nothing else). Pretty neat!


  1. This is really great! But I think there is also a use case for replaceState, or a count argument with clearState. There are cases where you want to update the current state in the history, instead of adding a new state: for example if you are navigating around a map, like Google maps.

    You don't want to remove all the state objects, like clearState does. Take f.e. Google Maps again: you want searches to add to the history, and they should not disappear from history if you navigate the map.

    Posted by Sjoerd Visscher at

  2. Put in other words, we want window.history.replaceState, just as there is window.location.replace.

    Posted by Mark Wubben at

  3. Really great news. Just hope not everybody does like Kudos and use AJAX for displaying the main content.

    Posted by Padfoot at