How do you make Firefox rerun javascript and reload the entire page when the user presses the back button? I was able to do this in all browsers except Firefox from the help of another SO question by adding this code:
history.navigationMode = 'compatible';
$("body").unload(function(){})
And also adding an iFrame... But this doesn't work in Firefox. Is there anything to do?
Firefox and Windows: To hard refresh on Firefox on Windows, there are also two easy hotkey commands you can use: Hold down Ctrl, Shift and the 'R' key. Or Hold down Ctrl and press F5.
Disable Auto-Refresh in Firefox Just type about:config into the Firefox address bar, “Accept the risks” involved in making changes to Firefox, then near the top of the list, you should see the preference called accessibility. blockautorefresh .
Clear Browser Cache and Cookies If clicking or tapping the Back button doesn't do anything or causes the same page to reload, clearing it might help fix things.
add this between your HEAD tags
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
In my case, after the final user Post his new data to server, he is redirected to another page. But when the final user press the back button, the form is pre-populated with the old data. So, reload page is needed.
I did a workaround for Firefox and another for Google Chrome. They have different behavior to show cached pages.
Doing this will prevent Firefox to cache the page and the back button will bring the page from server.
window.onunload = function(){};
But Google Chrome do it in another way and the solution above did not work for me. So I did another workaround for Chrome. I did a flag that mark the form as dirty.
At the top of <head>
, before load anything, I check the cookie
if(document.cookie.match(/my-form=dirty/)) {
document.cookie = "my-form=; expires=-1; path="+document.location.pathname;
window.location.reload();
}
With a help of jQuery, I write the cookie when user modify something
$(document).load(function(){
$(':input').change(function(){
document.cookie = "my-form=dirty; expires=86400000; path="+document.location.pathname;
})
})
Good to know:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With