0
点赞
收藏
分享

微信扫一扫

js制作页面返回、刷新和返回并刷新


1、返回上一页
js触发浏览器的返回属性主要用到封装好的window对象 history

history主要的三个方法是:

back()  加载 history 列表中的前一个 URL。
forward() 加载 history 列表中的下一个 URL。
go() 加载 history 列表中的某个具体页面。

实现方式可以使用:

history.back();
history.go(-1);

两个功能一样go()方法的使用功能更多

history.go(-2);//返回前两个页面

下面两个效果一样

history.go(1);
history.forward();


2、页面刷新

history.go(0);
location.reload();
location.href = location.href;


3、返回页面并刷新

window.location=document.referrer;








举报

相关推荐

0 条评论