页面无刷新超时自动退出

页面无刷新超时自动退出:

<script>
var JumpUrl = "",JumpTimer = 10;
var TimerCount = 0,Timer,IsStopJump = false;
var TimerOut = <%=10*60%>;
function $(_sId){return document.getElementById(_sId);}
function SetAutoJumpUrl(timers,url){JumpTimer = timers;JumpUrl = url;Timer = setTimeout("AutoJumpUrl()",1100);}
function AutoJumpUrl(){
   if(IsStopJump) return;
   if(TimerCount<(JumpTimer-1)){
    TimerCount ++;
    $('CountDown').innerText = JumpTimer-TimerCount;
    setTimeout("AutoJumpUrl()",1100);
   }else {
    document.location.href = JumpUrl;
   }
}
function HandJump(){
   if(IsStopJump == false){
    IsStopJump = true;
    $('DoStop').innerText="y";
    $('DoStop').title="恢复倒计时";
   }else{
    IsStopJump = false;
    $('DoStop').innerText="x";
    $('DoStop').title="停止倒计时";
    AutoJumpUrl();
   }
}
</script>
<body onmousemove="TimerCount=0;" onmouseover="TimerCount=0;" onkeydown="TimerCount=0;" onclick="TimerCount=0;" onmouseout="TimerCount=0;" onFocus="TimerCount=0;">
<font id="DoStop" face="Wingdings" onclick="HandJump();" style="cursor:hand;" title="停止倒计时">x</font>
<span id="CountDown"><script>document.write (TimerOut);</script></span>秒后自动退出
<script>SetAutoJumpUrl(TimerOut,"http://www.7di.net");</script>
</body>

 精简后:

 

<script>
var timeout=5;//单位秒
var timecount = 0;//时间计数
function timecheck(){
if(timecount<timeout){
	timecount++;
	setTimeout("timecheck()",1000);
}else{
	alert("超时");
}
}
</script>
  </head>
  
<body onmousemove="timecount=0;" onmouseover="timecount=0;" onkeydown="timecount=0;" onclick="timecount=0;" onmouseout="timecount=0;" onFocus="timecount=0;">
<script>timecheck()</script>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值