Reputation: 1209
This issue -was- solved in older versions of Safari (The Safari Back Button Problem). Although running the latest Safari (9.0.1), none of the solutions listed on the previous answer work anymore. Does anyone have a solution to "refresh/reload" the page when the back button on safari is used?
This -was- a way to detect if the page was accessed using the back-button. Although doesn't work in the version of Safari I'm using.
<body onunload="">
Upvotes: 9
Views: 9338
Reputation: 1582
Other answers bind things to window.onpageshow, but this is the only version that works for me: once your page is in a final state that you don't want to outlive a redirect, you can just bind the pageshow event and then check for the "persisted" property being true to determine if you should reload it.
window.addEventListener("pageshow", function(evt){
if(evt.persisted){
setTimeout(function(){
window.location.reload();
},10);
}
}, false);
Upvotes: 29