Reload the page when you visit by clicking the back button in Firefox.

I have a page that enlivens the entire body outside the viewing screen as a transition. It works fine, but when a user clicks the back button in a browser, Firefox displays a cached page from a history that has no body.

So I just need to reload the page when visiting using the "Back" button.

I tried the following code to reload the page to avoid reloading again.

<script type="text/javascript">
  window.onload=function(){
    var e=document.getElementById("refreshed");
    if(e.value=="no")e.value="yes";
    else{e.value="no";location.reload();}
  }
</script>
<input type="hidden" id="refreshed" value="no">

This did not solve the problem, since the anonymous function was not even called.

So, I tried setting the headers so that the browser does not cache the page.

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

This also did not solve the problem.

The page works fine in Chrome.

In Firefox version I use 12.0

Javascript, JQuery ?

+5
2

onload, .

, :

  • onpageshow ( ).
  • ( ).
  • .
+5

, setTimeout .

<script>
setTimeout(function() {
var e=document.getElementById("refreshed");
    if(e.value=="no")e.value="yes";
    else{e.value="no";location.reload();}
}, 1000);
</script>
0

All Articles