Forum Moderators: phranque

Message Too Old, No Replies

'onclose' script,

ie to run functions when browser or window is closed

         

anubis

9:52 pm on Feb 23, 2003 (gmt 0)

10+ Year Member



Hello

Has anyone out there asample of 'onclose' script, ie to run functions when browser or window is closed

cheers

anubis

anubis

10:03 pm on Feb 23, 2003 (gmt 0)

10+ Year Member



Anubis again to give you an bit more info on what I want to do I want to delete a cookie/info whenever the session ends ie when the user closes the window.

Cheers

LarryFowler

6:31 pm on Mar 4, 2003 (gmt 0)



I use the following code in a JSP page to execute code back on the servlet when an IE window is closed:

<SCRIPT language=JavaScript type="text/javascript"> <!--
function logout()
{
self.open("logout.jsp", "logout","width=100, height=100");
}

function checkClose() // for IE
{
if ((window.event.clientY < 0) ¦¦ (window.event.clientX < 0))
logout();
}
//--></SCRIPT>

HTML

<BODY onUnload="javascript:checkClose()">

I know this looks klugey but it works on the principle that the X in the upper right corner has negative (x,y) coordinates