views:

225

answers:

1

Is there a general purpose solution for preserving dom state so that when a user returns to a page by using back/forward, the whole page is in the exact state that they left it?

This post asks and answers why the behavior is inconsistent with different browsers and different javascript libraries...

http://stackoverflow.com/questions/1195440/ajax-back-button-and-dom-updates

...but I am curious if anyone has a general solution to this problem that doesn't require reloading the page.

+1  A: 

I'm afraid there isn't, and there really can't be because we're talking about browser behavior that's completely discretionary and not standards-defined. You could use Ajax to aggressively synchronize relevant DOM state to a session on a server, and always restore from that state on page load, but that will preserve the most recent state for that page, not the state that was necessarily present at a given desired point in the browser history.

chaos
Wow, it seems like this must be a universal problem for a lot of people. Maybe I will save state to the server during unload so that I can be sure to have the very latest changes. I do wish that all the browsers behaved like FF 3+ and just did the right thing on this.
Pete