以备后用,现转来放着:
你可以试试这样,在浏览器关闭的时候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去注销,不开新窗口
<script>
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>
调用这个吧用 height=0 width=0 <iframe> src 里调用结束 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去注销,不开新窗口
<script>
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>
调用这个吧用 height=0 width=0 <iframe> src 里调用结束 session 程序就可以