[js刷新页面的方法]js定时刷新页面方法总结

更新时间:2017-11-28    来源:js教程    手机版     字体:

【www.bbyears.com--js教程】

定时刷新:

1,利用setTimeout

 代码如下

<script language="JavaScript">
function myrefresh()
{
       window.location.reload();
}
setTimeout("myrefresh()",1000); //指定1秒刷新一次
</script>

说明:url是要刷新的页面URL地址

2000是等待时间=2秒,

2,利用meta中的Refresh刷新

 代码如下

< meta name="Refresh" content="n; url"> 说明:

n is the number of seconds to wait before loading the specified URL.

url is an absolute URL to be loaded.

n,是等待的时间,以秒为单位

url是要刷新的页面URL地址


Javascript刷新页面的几种方法:

 代码如下

1    history.go(0)
2    location.reload()
3    location=location
4    location.assign(location)
5    document.execCommand("Refresh")
6    window.navigate(location)
7    location.replace(location)
8    document.URL=location.href

本文来源:http://www.bbyears.com/wangyezhizuo/37377.html

热门标签

更多>>

本类排行