AJAX: Changing history

  • 0
  • April 1, 2011
Steven Shaw

Steven Shaw

Digital Director

Yeah, well history is going to changeMarty McFly once said: “Yeah, well, history is gonna change”, and if you’re using one of the latest Gecko 2 based web browsers, such as Firefox 4, Thunderbird 3.3 or SeaMonkey 2.1, then this just might be the case for you.

Ignoring the fact I wanted to get a Back to the Future quote on the blog, it seems that the new JavaScript methods that these browsers will support; will allow developers to make changes to the URL bar without refreshing the browsers or directing the user to the new URL. It also means that you could ‘inject’ browser history to the viewer, but we are sure there’s been some thought around the security of this.

So what exactly does this mean?

Well, imagine you’ve just done a search on Google and it’s given you a nice list of search results, then say you wanted to move to page two of those results, well rather than the whole page having to reload; Google could use AJAX to refresh just the central results area, meaning you didn’t need to load all the surrounding content/images/style sheets etc.

So that part is nothing new, but what they could now do is at the same time, change your URL bar to show something like: /page/2, and if you click again: /page/3. These new URLs would be neatly slotted into your browser history, meaning that you can return to the specific pages in the future (that is if you also create the static view of the results too or have AJAX check the query and re-render the results).

All in all, it’s a pretty neat way to start building a site that uses a lot of AJAX, but allows for those who need to return to the dynamic pages directly.

Free of charge. Unsubscribe anytime.