您的位置:首页 > Web前端 > JavaScript

js刷新页面和跳转

2015-07-10 17:18 821 查看

javascript返回上一页:

1、返回上一页 history.go(-1); 返回上两个页面 history.go(-2);

<a href="javascript:history.go(-1);">上一页</a>

2、history.back().

3、window.history.forward() 返回下一页

4、window.history.go(返回第几页,也可以是url)

5、window.location.href=url;

js刷新页面的几种方法:

1、history.go(0);

2、window.location.href=当前页面url;

3、location=location;

4、location.replace(location);

5、location.assign(location);

6、window.navigate(location);

7、document.URL=location.href

自动刷新页面的方法:

1、页面自动刷新:在<head>标签中加入

<meta http=-equiv="refresh" content="20">其中20指每隔20s刷新一次

2、页面自动跳转:在<head>标签中加入

<meta http=-equiv="refresh" content="20;url="http:www.baidu.com">其中20指20s后跳转到http://www.baidu.com

3、页面自动刷新,js

<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: