后退、返回上一页、返回上一步
window.history.go(-1) 可简写为: history.go(-1)
window.history.back() 可简写为: history.back()
前进、下一页
window.history.go(1) 可简写为: history.go(1)
window.history.forward() 可简写为: history.forward()
返回上一页并刷新
self.location=window.document.referrer 可简写为: self.location=document.referrer
刷新当前页
history.go(0)
location.reload()
location=location
location.assign(location)
document.execCommand('Refresh')
window.navigate(location)
location.replace(location)
document.URL=location.href
实例:
按钮调用
<input type="button" value="后退" onclick="window.history.go(-1)" />
<input type="button" value="返回上一页" onclick="history.back()" />
<input type="button" value="前进" onclick="window.history.go(1)" />
<input type="button" value="前进" onclick="window.history.forward()" />
<input type="button" value="返回上一页并刷新" onclick="self.location=window.document.referrer;" />
<input type="button" value="刷新" onclick="window.location.reload()" />
链接调用
<a href="javascript:history.go(-1);">后退</a>
<a href="javascript:" onclick="history.back()">返回上一页</a>
<a href="#" onclick="javascript:history.back();">返回上一步</a>
<a href="javascript:history.go(1);">前进</a>
<a href="#" onclick="history.forward();">前进</a>
<a href="javascript:" onclick="self.location=document.referrer;">返回上一页并刷新</a>
<a href="#" onclick="location.reload();">刷新</a>