当前位置: 首页 > 图文教程 > 网络编程 > ASP > 判断Session的过期时间 采用JavaScript实时显示剩余多少秒

ASP
asp下检查表中是否存在某个字段(列)函数
ASP批量更新代码
asp飞飞无限级分类v1.0 Asp+sql+存储过程+ajax提供下载
比较详细的ASP rs.open语句详细说明
可以应用到马克斯电影站生成Rss Feed的代码
ASP 无限级分类实现
从数据库中读取记录横向排列
ASP动态级联菜单实现代码
网上用的比较多的asp级联菜单效果代码
ASP提高数据显示效率-缓存探幽
asp经常被忽视的一种死循环
关于Asp代码与页面的分离模板技术
用GetString提高ASP的速度
用cookies实现闪电登录论坛方法
一个不太让人讨厌的自动弹出窗口
asp格式化日期时间格式的代码
ASP变量加变量实现代码
asp向数据库插入数据的方法rs
asp上传带显示的代码
asp防止垃圾留言代码

ASP 中的 判断Session的过期时间 采用JavaScript实时显示剩余多少秒


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 69 ::
收藏到网摘: n/a

判断Session的过期时间-采用JavaScript显示剩余多少秒 <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%session.timeout=1440 '单位(分钟)1440=24小时 参数不能大于24小时 也就是不能大于1440分钟%>
<%
if session("login")<>"888888" then'判断Session是否有效
Response.Write("Session过期了")
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
var lefttime=6 //session时间传递
var tid
function x()
{
lefttime--
document.all.xx.innerText="剩余:"+lefttime + "秒"
if(lefttime==0) {clearInterval(tid);document.all.xx.innerText="登录超时了" }
}
tid = window.setInterval("x()",1000)
</script>
</head>
<body>
<div id=xx></div>
http://www.ruanchen.com
</body>
</html>
能不能在时间到的时候弹出一个警告,点击之后进入另一画面?
<script>
var lefttime=3 //session时间传递
var tid
function x()
{
lefttime--
document.all.xx.innerText="剩余:"+lefttime + "秒"
if(lefttime==0)
{
window.clearInterval(tid);
if(window.confirm("您要进入吗?"))
window.open("http://www.ruanchen.com/")
}
}
tid = window.setInterval("x()",1000)
</script>
<body>
<div id=xx></div>
不要window.open打开另一个页面,要在原来的那个页面上打开新的页面。
将window.open("http://www.ruanchen.com/")改成
window.locaton.href="http://www.ruanchen.com"就行了