首页 > JizhiCms教程
JS后退、前进、返回上一页和刷新代码
JS后退代码:window.history.go(-1)可简写为:history.go(-1)window.history.back()可简写为:history.back()JS前进代码:window.history.go(1)可简写为:history.go(1)window.history.forward()可简写为:history.f...
#内容详情

JS后退代码:

window.history.go(-1)      可简写为:   history.go(-1)window.history.back()      可简写为:   history.back()

JS前进代码:

window.history.go(1)        可简写为:   history.go(1)window.history.forward()    可简写为:   history.forward()


JS返回上一页并刷新代码:

self.location=window.document.referrer     可简写为:   self.location=document.referrer


JS刷新代码:

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>


以上就是JS后退、前进、返回上一页并刷新代码的全部内容,希望能帮助到大家,更多网站建设教程建站代码请继续关注


点赞 ( 0 )
收藏
#评论
0+评论
上一页
下一页
发表