js实现HTML自动刷新页面和跳转(重定向)

来源:互联网 发布:淘宝客服技巧用语 编辑:程序博客网 时间:2024/05/02 00:29

实现自动HTML刷新页面和跳转页方法有很多,主要分为两类,一类为使用html head标签,另一类为使用js强制刷新或跳转。

1. 使用js 刷新当前页面,3秒执行一次。

<script language="JavaScript">  function Refresh()  {  window.location.reload();  }  setTimeout('Refresh()',3000); //3秒刷新一次  </script> 

2. 使用js 自动跳转页面,3秒后执行

<html>  <head>  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  <script language="javascript">  function goUrl()  {    var url="http://blog.csdn.net/haoaiqian";    location.href=url;  }  </script>  </head>  <body onload="setTimeout('goUrl()', 3000);">  </body>  </html> 
原创粉丝点击