joestelmach.com

Browser Back Button

I have a question. Why does the browser have to be so stupid about its back button? I realize that http is an overly simple protocol, but I just can't help but to think that we can implement a better back button. With the advent of sending http requests via ajax, the back, forward, and refresh buttons have gotten to be just about pointless. This is unfortunate since most people find the back button to be invaluable (try counting how many times you hit it in one day.)

The problem is that each state in the browser is represented by a complete page load. So when we go through an entire ajax request/response cycle, the browser is not pushed into the next state. My question is, why not? I realize that the browser is properly implementing the http protocol, but I can't help but wonder how much nicer the web would be if we could change this behavior. I also don't know that it would be that hard.

Consider the following sequence of events:

  1. Send an ajax request
  2. Receive the response
  3. Take a snapshot of the current DOM
  4. Manipulate the DOM as intended by the programmer
  5. Push the browser into the next state

In other words, imagine all of these steps completing, and then the user pressing the back button. The browser sould reload the DOM exactly as it was represented in steps 1-3. I realize I'm being an idealist here (I tend to be,) but I can't stop thinking about how cool this would be. We could make the browser truly event-based instead of page load based by simply caching each snapshot of the DOM on each request/response cycle (ajax or traditional.)

Ofcourse, this idea may not be perfect. We still have a problem with the URL being the same across multiple events (or 'states'.) One of the main complaints against using ajax (or even dhtml in general,) is that bookmarking becomes impossible. But wouldn't it be great if you could bookmark a page after making several ajax requests? Maybe the browser could actually remember how it got back to the state that was bookmarked by remembering the sequence of events that occured after the last complete page load (I'll admit, this would be hard to implement, especially when we start mixing get and post requests.) But would it really be impossible. Do we really need a new protocol to handle this?

Comments
blog comments powered by Disqus