js 怎么定时刷新指定页面

如题所述

第1个回答  2018-04-13
有两种刷新方法:
第一种:setTimeout("window.location.replace('url')",10);
第二种方法:setInterval("window.location.replace('url')",60);
//定时器的时间单位为毫秒,1s=1000ms;
第2个回答  2015-12-02
  将<metahttp-equiv=\\\"refresh\\\"content=\\\"20\\\">添加到head中,content=\\\"20\\\"指每隔20秒刷新一次页面.

  也可以用下面的JS控制

  <scriptlanguage=\\\"JavaScript\\\">

  functionmyrefresh(){

  window.location.reload();

  }

  setTimeout(\\\'myrefresh()\\\',1000);//指定1秒刷新一次

  </script>

  或者是

  functionrefresh()

  {

  window.location.href=\\\"当前页面URL\\\";

  setTimeout(\\\"refresh()\\\",10000);

  }本回答被提问者采纳
相似回答