Idea is to display message, which will infor muser that ajax part of application can wokr incorrectly when he used "back" button. Yes, there is a lot of discussions, but no solutions. Best from what I found: Store information about last page on server side, and check current page against server info by ajax. But in this way it would be impossible to use 2 browser windows by same user.
A:
The real solution is to let the client maintain state, rather than your server. You're breaking the laws of the Internet if you keep so much client state on your server that the back button doesn't work :)
Wahnfrieden
2009-08-21 16:32:48
I agree that it would be mouch more correct tpo have it working after back.However, this is out of scope and budget.
Sergey Osypchuk
2009-08-21 16:37:28
+1
A:
You might want to develope using the url #(hash) to store client state
take a look at http://www.asual.com/swfaddress/, it is used by Flash and ajax to handle browser history with ajax,
Silverlight 3.0 uses a similar technique of using the #(hash) in the url for state.
BigBlondeViking
2009-08-21 16:42:46
In case it is not clear, this technique means the content will be always dynamically loaded by a script in your site. It means you control what happens, actually it will naturally behave like there's no Back button, content will be always renewed. Google use this on Gmail and Orkut sites.
Havenard
2009-08-21 17:03:04
@Havenard: -> "always dynamically loaded" is not exactly true, you can pre-populate the page with content generated from the server(gracefully degrade should there be no JS or JS issue), then when the state changed beyond that initial load, yes all content is "ajax-ed" in. but you are on the money (+1 comment)
BigBlondeViking
2009-08-21 17:10:02
A:
This solution may or may not apply to your case, and it may or may not work with your browser. It seemed to work for me on IE7 where each page had a distinct "widget Id" referenced in the URL querystring -
//try to detect a bad back-button usage;
//widgetId not match querystring parameter did=#
var mustReload = false;
if (location.search != null &&
location.search.indexOf("&did=") > 0)
{
var urlWidgetId = location.search.substring(
location.search.indexOf("&did=")+5);
if (urlWidgetId.indexOf("&") > 0)
{
urlWidgetId = urlWidgetId.substring(
0,urlWidgetId.indexOf("&"));
}
if (currentDashboard != urlWidgetId)
{
mustReload = true;
}
}
if (mustReload)
{
... //reload the page to resynch here
}
Steven A. Lowe
2009-08-21 16:52:55