js刷新页面和跳转

mac2022-06-30  29

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>

 

转载于:https://www.cnblogs.com/chengkun101/p/4636282.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)