[英]Reload the page when visited by clicking Back button in Firefox
我有一个页面,可以将整个身体动画出观众的屏幕,作为过渡。 它可以正常工作,但是当用户在浏览器中单击“后退”按钮时,Firefox从没有正文的历史记录中弹出缓存的页面。
因此,通过后退按钮访问页面时,重新加载页面非常简单。
我尝试使用以下代码重新加载页面,以避免重复加载。
<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">
它没有解决问题,因为甚至没有调用匿名函数。
因此,我尝试设置标题,以使浏览器不会缓存该页面。
<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">
它还没有解决问题。
该页面在Chrome中运行良好。
我使用的Firefox版本是12.0
如何使用Javascript,JQuery或任何其他客户端脚本重新加载页面?
导航回内存中缓存的页面时不会触发onload事件。
我认为您有三个主要选择:
我没有尝试过,但是setTimeout可能会有所帮助。
<script>
setTimeout(function() {
var e=document.getElementById("refreshed");
if(e.value=="no")e.value="yes";
else{e.value="no";location.reload();}
}, 1000);
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.