通过单击Firefox中的“返回”按钮访问页面时重新加载页面 [英] Reload the page when visited by clicking Back button in Firefox

查看:226
本文介绍了通过单击Firefox中的“返回”按钮访问页面时重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,将整个身体从观看者的屏幕中移出来作为转换。它工作正常,但当用户点击浏览器中的后退按钮时,Firefox会弹出历史记录中没有正文的缓存页面。



所以对我来说很简单重新加载页面时,通过后退按钮访问。



我已经尝试了下面的代码来重新加载页面,以避免重新加载。
$ b

 < script type =text / javascript> 
window.onload = function(){
var e = document.getElementById(刷新);
if(e.value ==no)e.value =yes;
else {e.value =no; location.reload();}
}
< / script>
< input type =hiddenid =refreshedvalue =no>

没有解决问题,因为匿名函数甚至没有被调用。 >



所以我试着设置标题,这样浏览器就不会缓存页面。

 < meta http-equiv =Cache-Controlcontent =no-cache,no-store,must-revalidate> 
< meta http-equiv =Pragmacontent =no-cache>
< meta http-equiv =Expirescontent =0>

这个问题也没有解决。



该页面在Chrome中正常工作。



我使用的Firefox版本是12.0

如何使用Javascript,JQuery或任何其他客户端脚本来重新加载页面? 没有onload事件,当浏览返回到内存缓存页面时触发。

您有三个主要选项,我认为:


  1. 使用onpageshow事件(导航到缓存页面时触发 )。通过添加一个卸载事件监听器
    (它可以是一个空函数)来为你的页面提供缓存。
  2. 不要执行烦人的卸载动画
  3. b $ b


I have a page which animates entire body out of the viewer's screen as a transition. It works fine but when user clicks back button in the browser Firefox brings up the cached page from the history which does not have a body.

So it is simple enough for me to reload the page when visited via the back button.

I've tried the following code to reload the page so as to avoid repeted reloading.

<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">

It did not solve the issue as the anonymous function was not even invoked.

So I tried setting the headers so that the browser would 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">

It also did not solve the issue.

The page works fine in Chrome.

The version of Firefox I use is 12.0

How can I get the page to reload using Javascript, JQuery or any other client side scripts ?

解决方案

There is no onload event that fires when navigating back to an in-memory-cached page.

You have three main options, I think:

  1. Use the onpageshow event (which does fire when navigating to a cached page).
  2. Prevent in-memory caching of your page by adding an unload event listener (which can just be an empty function).
  3. Don't do the annoying unload animation.

这篇关于通过单击Firefox中的“返回”按钮访问页面时重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆