I have a challenging problem I\'ve been battling for some time now.
The Problem: when I go back to previous page using browser\'s back button, the page is d
The above answers touch on the problem, but provide hacky ways to solve the question. This seems to be the proper way to do it.
$(window).bind('pageshow',function(){
alert("This page will run even if the back button was pressed!");
});
To read more on the pageshow/pagehide events see here: http://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/
You could can take it a step further like this:
$(window).bind('pageshow',function(e){
if (e.persisted) {
alert("pageshow event handler called. The page was just restored from the Page Cache.");
} else {
alert("pageshow event handler called for the initial load. This is the same as the load event.");
}
}