JS之页面自动跳转

来源:互联网 发布:手机全局透明软件 编辑:程序博客网 时间:2024/06/11 16:26


10秒后跳转到指定页面

 <body>  <h1>操作成功</h1>  <p><span id="counts">10</span>秒后回到主页 <a href="javascript:back();">返回</a></p>  <script type="text/javascript">     var count=document.getElementById("counts").innerHTML;   function countTimer()   {           count--;      //获取显示秒数的元素,通过定时器来更改秒数。      document.getElementById("counts").innerHTML=count;      if(count==0)      {         location.assign("www.imooc.com");      }         }   setInterval("countTimer()",1000);   //通过window的location和history对象来控制网页的跳转。   function back()   {      window.history.back();   } </script> </body>


0 0
原创粉丝点击