返回上一个页面并且刷新

文章出自https://blog.csdn.net/yanwuxpp/article/details/70238697


经常遇到一些页面跳转的问题,当我们用window.history.go()/window.history.back()/window.history.forward(),只能实现页面返回上一页,但是却无法刷新返回到的页面,所以,总结(解析)如下方法:(从a.html跳转到b.html)

<script>
function goback(){
window.history.go(-1);//正常返回,a.htm不刷新

window.history.back();//同上

window.history.forward();//同上



window.opener.location.reload();// 只有当该页面为新窗口时有效,即<a href="b.html" target="_blank">b.html</a>
window.opener.location.href   =   window.opener.location.href ;//同上

window.parent.location.reload();//框架页中有效

document.parentWindow.location.reload();//刷新的是自己

window.location.href ="a.htm"//不断刷新a.html
}

</script>

<body>

<A href="history.html" οnclick="javascript:location.replace(this.href);event.returnValue=false; ">方法一:返回上一页并刷新页面</A> 
<a href="javascript:" οnclick="self.location=document.referrer;">方法二:返回上一页并刷新</a> 
<a href="javascript:window.history.go(-1)">方法三:返回上一页,不刷新history.html</a>
<a href="javascript:document.parentWindow.location.reload()">方法四:返回上一页面刷新的是自己</a>

</body>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值