html和JavaScript,用户点击浏览器后退按钮,或者返回上一步自动刷新方式


推荐下我的AI导航网站:https://aijourney.vip/

浏览器用户返回上一步,自动刷新
方式一、
<input type="hidden" id="refreshed" value="no">
<script type="text/javascript">
onload=function(){
var e=document.getElementById("refreshed");
if(e.value=="no")e.value="yes";
else{e.value="no";location.reload();}
}
</script >
方式二、
header("Cache-Control: no-store, must-revalidate, max-age=0");
header("Pragma: no-cache");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
方式三、
window.onpageshow = function(event) {
if (event.0) {
    window.location.reload() 
}
};

 转载注明出处:https://www.cnblogs.com/cblogs/p/6126387.html

posted @ 2016-12-02 16:49  程序员阿超的博客  阅读(17960)  评论(2编辑  收藏  举报