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?
For reference, that navigationMode property only applies to Opera, it's just that IE and the Webkit browsers already have the behavior the questioner wanted.
IE and Webkit do what Opera would call "compatible" navigation. Firefox does what Opera would call "fast" navigation. But it's only in Opera that this behavior is actually controllable.
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.
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 cookieWith a help of jQuery, I write the cookie when user modify something
Good to know:
I think the answer you might want is here: https://stackoverflow.com/a/5493543/1475148
TLDR: HTTPS +
Cache-Control: must-revalidate
as a server-sent header +Expires
header set in the past should make it work. Here’s a sample PHP implementation:This solution worked for me (and I believe is a bit simpler than other solutions suggested):
I call this code on every page load, if the browser is FireFox. (To find out if the currently running browser is Firefox, see here).
None of this worked for me. I do it via cookies checking - I import jsp (source below) in head part of page, and then I call refreshOnBack in .
If your using c# .Net, you can handle it on the page load or init event programmatically
For more info, check out Response.Cache at MSDN: http://msdn.microsoft.com/en-us/library/system.web.httpresponse.cache(v=vs.110).aspx