本文介绍了从网页自动注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想是有时被用户闲置,但不能够做,我后自动使用了JavaScript的follwing但没有什么是怎么回事,我也加入会话超时在web配置,但其也没有working.Please给我一些想法。
<脚本类型=文/ JavaScript的>
VAR定时器,定时器;
document.onkey preSS = resetTimer;
document.onmousemove = resetTimer;
功能resetTimer()
{
。的document.getElementById('timeoutPopup')的style.display ='无';
clearTimeout(定时器1);
clearTimeout(定时器2); //等待时间(分钟)
VAR等待= 10; //警告用户前一分钟
定时器1 =的setTimeout(alertUser(),(60000 *等待)-1); //注销用户
定时器2 = setTimeout的(退出(),60000 *等);
} 功能alertUser()
{
。的document.getElementById('timeoutPopup')的style.display =块;
} 函数注销()
{
window.location.href ='Logout.aspx';
}} < / SCRIPT>
解决方案
有关setTimeout的第一个参数是一个函数句柄。
<脚本类型=文/ JavaScript的>
VAR定时器,定时器;
document.onkey preSS = resetTimer;
document.onmousemove = resetTimer;
功能resetTimer()
{
。的document.getElementById('timeoutPopup')的style.display ='无';
clearTimeout(定时器1);
clearTimeout(定时器2);
//等待时间(分钟)
VAR等待= 10; //警告用户前一分钟
定时器1 = setTimeout的(alertUser,(60000 *等待)-1); //注销用户
定时器2 = setTimeout的(注销,60000 *等);
} 功能alertUser()
{
。的document.getElementById('timeoutPopup')的style.display =块;
} 函数注销()
{
window.location.href ='Logout.aspx';
}}< / SCRIPT>
I want to automatically after being sometimes idle by the user but not being able to do.I has used follwing javascript but nothing is going on and I have also add session timeout in web config but its also not working.Please give me some ideas.
<script type="text/javascript">
var timer1, timer2;
document.onkeypress=resetTimer;
document.onmousemove=resetTimer;
function resetTimer()
{
document.getElementById('timeoutPopup').style.display='none';
clearTimeout(timer1);
clearTimeout(timer2);
// waiting time in minutes
var wait=10;
// alert user one minute before
timer1=setTimeout("alertUser()", (60000*wait)-1);
// logout user
timer2=setTimeout("logout()", 60000*wait);
}
function alertUser()
{
document.getElementById('timeoutPopup').style.display='block';
}
function logout()
{
window.location.href='Logout.aspx';
}
}
</script>
解决方案
First argument for setTimeout is a function handle. JS Timing
<script type="text/javascript">
var timer1, timer2;
document.onkeypress=resetTimer;
document.onmousemove=resetTimer;
function resetTimer()
{
document.getElementById('timeoutPopup').style.display='none';
clearTimeout(timer1);
clearTimeout(timer2);
// waiting time in minutes
var wait=10;
// alert user one minute before
timer1=setTimeout(alertUser, (60000*wait)-1);
// logout user
timer2=setTimeout(logout, 60000*wait);
}
function alertUser()
{
document.getElementById('timeoutPopup').style.display='block';
}
function logout()
{
window.location.href='Logout.aspx';
}
} </script>
这篇关于从网页自动注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!