• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
maxthon
博客园    首页    新随笔    联系   管理    订阅  订阅
一分钟不操作自动将页面跳转到另一个页面
一分钟不操作自动将页面跳转到另一个页面

一分钟不操作自动将页面跳转到另一个页面

<script>  
  function   go()  
  {  
  location.href="index.html";  
  }  
  function   notgo()  
  {  
  clearTimeout(mygo);  
  mygo=setTimeout(go,60000);  
  }  
  document.onmouseover=notgo;  
  document.onmousemove=notgo;  
  document.onmouseout=notgo;  
  document.onmousedown=notgo;  
  document.onmouseup=notgo;  
  document.onkeydown=notgo;  
  mygo=setTimeout(go,60000);  
  </script>

 

以下是15秒后页面自动跳转的另一种写法

<script>  
  <!--    
  var   limit="0:15"  
  if   (document.images){  
  var   parselimit=limit.split(":")  
  parselimit=parselimit[0]*60+parselimit[1]*1  
  }  
  function   beginrefresh(){  
  if   (!document.images)  
  return  
  if   (parselimit==1)  
  window.location.href="index.html"  
  else{    
  parselimit-=1  
  curmin=Math.floor(parselimit/60)  
  cursec=parselimit%60  
  if   (curmin!=0)  
  curtime=curmin+"分"+cursec+"秒后转向!"  
  else  
  curtime=cursec+"秒后转向!"  
  window.status=curtime  
  setTimeout("beginrefresh()",1000)  
  }  
  }  
  window.onload=beginrefresh  
  //-->  
  </script>

 

 

 


posted on 2009-01-13 09:57  新农民  阅读(558)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3