经常遇到一些页面跳转的问题,当我们用window.history.go()/window.history.back()/window.history.forward(),只能实现页面返回上一页,但是却无法刷新返回到的页面,所以,总结(解析)如下方法:(从a.html跳转到b.html)
<script>
function goback(){
window.history.go(-1)
window.history.back()
window.history.forward()
window.opener.location.reload()
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" onclick="javascript:location.replace(this.href);event.returnValue=false; ">方法一:返回上一页并刷新页面</A>
<a href="javascript:" onclick="self.location=document.referrer;">方法二:返回上一页并刷新</a>
<a href="javascript:window.history.go(-1)">方法三:返回上一页,不刷新history.html</a>
<a href="javascript:document.parentWindow.location.reload()">方法四:返回上一页面刷新的是自己</a>
</body>