After the user logs on to the system, if no action is made, the system will automatically pop up a dialog box prompting the user to sign in again after a specified time.
The code is as follows:
<script type= "Text/javascript" >
var timer;
var wait = 20; Waiting time in minutes
Document.onmousemove = Resettimer;
function Resettimer () {
var timeoutpopup_display = document.getElementById (' Div_timeoutpopup '). Style.display;
if (timeoutpopup_display! = "Block") {
Cleartimeout (timer);
}
timer = setTimeout ("Logout ()", 60000 * wait); //60000 = 60 Seconds
}
Function logout () {
document.getElementById (' Div_background '). style.display = ' block ';
document.getElementById (' div_ Timeoutpopup '). style.display = ' block ';
document.getElementById (' Expired_text '). style.display = ' block ';
document.getElementById (' btn_logout '). Style.display = ' inline-block ';
}
</script>
Add two div to the foreground interface
<div id= "Div_background" style= "display:none; width:100%;height:100%; position:fixed;top:0px;left:0px;
Background-color: #030303; Filter:progid:DXImageTransform.Microsoft.Alpha (opacity=80); Filter:alpha (opacity=80); opacity:0.8; " >
</div>
<div id= "Div_timeoutpopup" align= "center" class= "Timeoutpopup" >
<span id= "Expired_text" style= "Font-size:14px;display:none" ><br/><br/><br/>Your session Has expired!<br/><br/><br/></span>
<input type= "button" id= "Btn_logout" value= "log-in Again" style= "Height:30px;width:100px;display:none;" onclick= " location.href= ' adminlogin.aspx ' "/>
</div>
The CSS code is as follows:
. timeoutpopup
{
Display:none;
position:fixed;
top:0; right:0; bottom:0; left:0;
width:30%;
height:25%;
Margin:auto;
padding:4px;
Border:solid 2px #999999;
Background-color: #EAEAEA;
Text-align:center;
}
Effect
ASP. NET implements automatic Logout