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

所属分类: 网络编程 / ASP编程 阅读数: 1777
收藏 0 赞 0 分享
<%@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>
https://www.jb51.net
</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("https://www.jb51.net/")
}
}
tid = window.setInterval("x()",1000)
</script>
<body>
<div id=xx></div>
不要window.open打开另一个页面,要在原来的那个页面上打开新的页面。
将window.open("https://www.jb51.net/")改成
window.locaton.href="https://www.jb51.net"就行了
更多精彩内容其他人还在看

ASP 指南

ASP 指南
收藏 0 赞 0 分享

改进 ASP 的字符串处理性能

改进 ASP 的字符串处理性能
收藏 0 赞 0 分享

pjblog2的参数第1/2页

pjblog2的参数
收藏 0 赞 0 分享

ASP智能搜索的实现

ASP智能搜索的实现
收藏 0 赞 0 分享

网站生成静态页面攻略2:数据采集

网站生成静态页面攻略2:数据采集
收藏 0 赞 0 分享

网站生成静态页面攻略3:防采集策略

网站生成静态页面攻略3:防采集策略
收藏 0 赞 0 分享

网站生成静态页面攻略4:防采集而不防搜索引擎策略

网站生成静态页面攻略4:防采集而不防搜索引擎策略
收藏 0 赞 0 分享

简单分页函数一 常用

简单分页函数一 常用
收藏 0 赞 0 分享

asp最常用的分页函数

asp最常用的分页函数
收藏 0 赞 0 分享

LINE9的目录浏览源程序

LINE9的目录浏览源程序
收藏 0 赞 0 分享
查看更多