关闭浏览器同时注销session

方法一:

你可以试试这样,在浏览器关闭的时候open出一个隐藏的窗口来注销session,注销后再close这个页面  

<script>   
function   window.onbeforeunload() {   
   if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey) {   
    window.open('out.jsp','','height=100,width=100,top=5000,left=5000,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,   status=no')   
    }   
}   
</script>   

 
out.jsp  
----------------------------  

 

<%   
//这里注销session   
%>   
<script>   

window.close();   
</script>

 
---------------------------------------------------------------------------------------------------

方法二:


只是现在拦截弹出窗口的插件太多了,好像比较不保险  
怕拦截窗口的插件给拦截的话可以是是在脚本中用xmlhttp   :

<script>   
function   window.onbeforeunload(){   
	if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey){   
	// 在这里用xmlhttp
	}   
}  

// 用xmlhttp去注销,不开新窗口
  
function window.onbeforeunload(){   
	if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey){   
	var   xmlhttp   =   new   ActiveXObject("Microsoft.XMLHTTP");   
	xmlhttp.open("GET",   "out.jsp",   false);   
	xmlhttp.send();       
	}   
}   
</script>

 
---------------------------------------------------------------------------------------------------

方法三:

<script   language="javaScript">   
function   removeline(){   
if(event.clientX<0&&event.clientY<0)   
{   
document.write('<iframe   width="100"   height="100"   src="page/removeline.jsp"></iframe><OBJECT   classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2   height=0     id=WebBrowser   width=0></OBJECT>');   
document.all.WebBrowser.ExecWB(45,1);   
}   
}   
</script>

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shibushi114

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值