发布时间:2025-12-10 19:47:57 浏览次数:3
window.history.go()和history.back()以及location.reload()的用法以及不同「建议收藏」window.history.go(-1);返回上一页,原页面表单中的内容会丢失;window.history.back(-1);返回上一页,原页面表单中的内容会保留.以下为举例:<inputtype=”button”value=”刷新”onclick=”window.location.reload()”><inputtype=”butto…_window.location.reload会改变history长度吗
window.history.go(-1); 返回上一页, 原页面表单中的内容会丢失;window.history.back(-1); 返回上一页, 原页面表单中的内容会保留.希望我今天分享的这篇文章可以帮到您。
以下为举例:
<input type="button" value="刷新" onclick="window.location.reload()"><input type="button" value="前进" onclick="window.history.go(1)"><input type="button" value="后退" onclick="window.history.go(-1)"><input type="button" value="前进" onclick="window.history.forward()"><input type="button" value="后退" onclick="window.history.back()"><input type="button" value="后退+刷新" onclick="window.history.go(-1);window.location.reload()">关于刷新:
window.history.go(0); 是直接读取缓存数据,不会从服务器端获取数据;window.location.reload(true); 不管有没有缓存,都会强制刷新;window.location.reload(false); 有缓存就走缓存,没缓存就强制刷新;