最主要的问题是关闭浏览器的时候如何更新用户在线列表
网上流传的方法是不停的ajax异步发送请求,当不再请求的时候就可以判断用户已经关闭浏览器
代码如下:
var x=0;
function myRefresh()
{
var httpRequest = new ActiveXObject(“microsoft.xmlhttp”);
httpRequest.open(“GET”, “test.aspx”, false);
httpRequest.send(null);
x++;
if(x<60) //60次,也就是Session真正的过期时间是30分钟
{
setTimeout(“myRefresh()”,30*1000); //30秒
}
}
myRefresh();
function myRefresh()
{
var httpRequest = new ActiveXObject(“microsoft.xmlhttp”);
httpRequest.open(“GET”, “test.aspx”, false);
httpRequest.send(null);
x++;
if(x<60) //60次,也就是Session真正的过期时间是30分钟
{
setTimeout(“myRefresh()”,30*1000); //30秒
}
}
myRefresh();
在web.config中设置:
<sessionState mode=”InProc” timeout=”1″></sessionState>
—-想了解更多的linux相关异常处理怎么解决关注<计算机技术网(www.ctvol.com)!!>
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/htmltutorial/73199.html