asp.net实现自动logout
来源:互联网 发布:手机淘宝上怎么开店铺 编辑:程序博客网 时间:2024/05/18 20:13
本文实现的自动logout是基于javascript代码实现的,用户登录系统后,如果没有进行任何操作,规定时间后,系统会自动弹出对话框,提示用户重新登录。
代码如下:
<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秒
}
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>
在前台界面上增加两个div
<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>
css代码如下:
.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;
}
效果如图
- asp.net实现自动logout
- asp.net代码实现自动发送邮件
- asp.net 实现自动发送email
- [ASP.NET] 实现Label自动换行
- asp.net实现关注自动回复
- asp.net实现页面局部自动刷新
- 一些AIX问题,自动logout
- ASP.NET+自动搜索
- 在asp.net中长内容自动分页的实现
- 在asp.net中长内容自动分页的实现
- asp.net中长内容自动分页的实现
- Asp.net 2.0 自定义控件开发[实现自动计算功能]
- 在ASP.Net中长内容自动分页的实现
- asp.net中长内容自动分页的实现
- 在ASP.NET中长内容自动分页的实现
- 在asp.net中长内容自动分页的实现
- 在asp.net中长内容自动分页的实现
- 在asp.net中长内容自动分页的实现
- 我的学习之旅(33) sched.h
- 奋斗需要战友
- coco2d-x 下载网络图片
- 菜鸟学JS(四)——javascript为按钮注册回车事件(设置默认按钮)
- iOS开发之UIWebView
- asp.net实现自动logout
- 大小不固定的图片和多行文字的垂直水平居中
- 自定义进度条
- 小程序员之----年终总结(1)
- 我的学习之旅(29)Makefile
- zoj 1151 Word Reversal
- UIWebView的使用
- 个人代码中常用的宏定义
- nagios安装