当前位置:编程学习 > JS >>

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

补充:网页制作,js教程 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,