以备后用,现转来放着:

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

<script>

functionwindow.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>

functionwindow.onbeforeunload()

{

if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)

{

//在这里用xmlhttp

}

}

//用xmlhttp去注销,不开新窗口

<script>

functionwindow.onbeforeunload()

{

if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)

{

varxmlhttp=newActiveXObject("Microsoft.XMLHTTP");

xmlhttp.open("GET","out.jsp",false);

xmlhttp.send();

}

}

</script>

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

方法三:

<scriptlanguage="javaScript">

functionremoveline(){

if(event.clientX<0&&event.clientY<0)

{

document.write('<iframewidth="100"height="100"src="page/removeline.jsp"></iframe><OBJECTclassid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2height=0id=WebBrowserwidth=0></OBJECT>');

document.all.WebBrowser.ExecWB(45,1);

}

}

</script>

调用这个吧用height=0width=0<iframe>src里调用结束session程序就可以