如题,用js改怎么去实现,

解决方案 »

  1.   

    <head>
      <meta http-equiv="refresh" content="600/*(刷新间隔:秒)*/">
    </head>
      

  2.   


    <script>
    function doit(){
      location.reload();
    }
    var tid;window.onfocus=function(){
       tid = setTimeout("doit()", 3000);
    }
    window.onblur=function(){
    clearTimeout(tid)
    }window.onload=function(){
       document.body.disabled = true;
       tid = setTimeout("doit()", 3000);
    }
    </script>
      

  3.   

    每隔5秒更新刷本页
    <meta http-equiv="refresh" content="5">1分钟后跳转至其他页面
    <meta http-equiv="Refresh" content="60;URL=/要刷新的页面"> 脚本刷新  
      <script   language="javascript">   
      setTimeout("window.location.reload(true)",5000);   
      </script>
      

  4.   

    setTimeout("window.location.reload(true)",5000);  
    这句我在页面中早就用过了,主要是不知道用js判断当前页面是否为活动页面.
    如果能判断就什么功能都能实现了
      

  5.   

     JS 定时器 (setInterval 和 setTimeout 函数)
    DEMO1:
    <html><head><script language="JavaScript">
    <!--function Refresh()
    {
     var newDateObj = new Date();
     document.form1.txt_Time.value=newDateObj.toLocaleString();//使用当前区域设置并已被转换为字符串
    }var MyInterval=setInterval("Refresh()",1000);function Stop()
    {
     if(event.srcElement.value=="STOP")
     //if(document.form1.btn_Stop.value=="STOP")
     {
      clearInterval(MyInterval);
      document.form1.btn_Stop.value="START";
     }
     else if(event.srcElement.value=="START")
     //else if(document.form1.btn_Stop.value=="START")
     {
      MyInterval=setInterval("Refresh()",1000);
      document.form1.btn_Stop.value="STOP";
     }
    }function Clear()
    {
     if(event.keyCode==8)//退格键
     {
      event.srcElement.value="";
     }
    }
    //-->
    </script>
    </head>
    <body><form name="form1">
    当前时间:<input type=text name="txt_Time" size=30 onkeydown="Clear()">
    <input type="button" name="btn_Stop" value="STOP" onClick="Stop()">
    </form></body></html>
    DEMO2:
    <SCRIPT>function Refresh()
    {
     Time.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());
     setTimeout("Refresh()",1000);
    }var timer=setTimeout("Refresh()",1000);function Stop()
    {
     if(event.srcElement.value=="STOP")
     {
      clearTimeout(timer);
      document.all.btn_Stop.value="START";
     }
     else if(event.srcElement.value=="START")
     {
      timer=setTimeout("Refresh()",1000);
      document.all.btn_Stop.value="STOP";
     }
    }</SCRIPT><body>
    <DIV style="background-color:#eeeeee" id="Time"></DIV>
    <input type="button" name="btn_Stop" value="STOP" onClick="Stop()"><button name='btnTest' onclick="javascript:alert(this.name)">测试</button>
    </body>
      

  6.   

    L@_@K
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
     </head> <body>
    <div id="divOutput"></div>
      <script type="text/javascript">
      <!--
    var div = document.getElementById("divOutput");window.onblur = function() {
    div.innerHTML = "Blur " + new Date() + "<br />" + div.innerHTML;
    };window.onfocus = function() {
    div.innerHTML = "Focus " + new Date() + "<br />" + div.innerHTML;
    };  //-->
      </script>
     </body>
    </html>
      

  7.   

    补充一句,window.onfocus 时启动定时器,window.onblur 时终止定时器!Web 开发常用手册JScript语言参考.rar
    http://download.csdn.net/source/308916DHTML参考手册.rar
    http://download.csdn.net/source/308913样式表中文手册.chm
    http://download.csdn.net/source/304124
      

  8.   

    setTimeout("doit()", 3000);
      

  9.   

    在IE里好像还有BUG,就是有时点击内容.也会运行一次
      

  10.   

    调试一下,上面的那些例子在FF3.5通过,但在IE7有问题.
    比如页面只有一两行内容.这样点击一下.页面没内容的空白部分.也当是失去焦点了.
      

  11.   

    这个是IE的document的高度问题,利用js把body设高一点,跟浏览器一样高