Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close window event on server side

Status
Not open for further replies.

netangel

Programmer
Feb 7, 2002
124
PT
New hot stuff to solve on my hands:

How can I catch a window closing on server side code?
I'll explain better. My app alows login/logout facility. I'm already saving the login info (user, date, time, ip). Now I need a full record of logout too. I have a logout link, but most people just close the window.
I think I've done it with client script (just need to search for it), but I can't figer out a way of catch it on the server (so I can save logout info - user, date, time).

Any ideas?

NetAngel
 
Hey NA,

we just added
onunload='javascript:window.open(logoff.aspx)'
to our page's body tag.

Then, in logoff.aspx, there's one sub that performs the logout, then the window closes itself. You just set the window small enough so that the user never really sees it.

As well, we then put code in the session_onend (just in case something buggers up with the logoff.aspx).

keep in mind though that we're using a 'connection' variable to determine if the person is logged in or not, and thats all that ever gets saved/deleted; not sure how your security model works or if its similar.

hth

D
 
I used this javascript funtion to open a popup window showing an animated gif, and then close the popup with the body unload event.

<SCRIPT language='javascript'>
var popped;

function popUp(){
popped = 1;
var url = &quot;popup.htm&quot;;
popWindow = window.open(url, 'popup', 'width=200, height=200, left=150, top=100);
}

function closeWindow(){
if(popped == 1){
popWindow.close();
}
}
</SCRIPT>

I use the body unload event to call the function closeWindow after all the processing is done.

onunload=&quot;closeWindow();&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top