登录超时功能js写法



function Timeout(){
alert('您的登录超时,请重新登录');
document.location.href='https://www.baidu.com';
}

var myTime=setTimeout('Timeout()',1000);
function restTime(){
clearTimeout(myTime);
myTime=setTimeout('Timeout()',1000); //再一次设置定时器
}

document.documentElement.onkeydown=restTime();
document.documentElement.onclick=restTime();
document.documentElement.onmousemove=restTime();

posted on 2017-04-26 21:11  村长有点忙  阅读(217)  评论(0编辑  收藏  举报

导航