Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > HTML and JavaScript

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-11-2004, 03:19 AM   #1
mkeefe
Registered User
 
Join Date: Sep 2004
Posts: 3
Default execute final code on window close

Hello,

I am looking for a way to have a piece of code executed when the user closes the browser window.

Here is an example.

I have a management program that the user logs into. If they "logout" the user is dropped from the database, but if the user just closes the browser they stay logged in. Any idea how I might get this to work?

-matt
mkeefe is offline   Reply With Quote
Old 11-11-2004, 03:42 AM   #2
tris
Registered User
 
Join Date: Nov 2004
Posts: 163
Default

You could try putting a onclose="doStuffHere()" inside your body tag. Or you could chnage the session timeout time e.g. if using ASP this would end the session after 10 minutes of inactivity.
Session.Timeout = 10
tris is offline   Reply With Quote
Old 11-11-2004, 04:23 AM   #3
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
Default

Um... How do you actually check if the user pressed the X button to close the window??? Then, there is no way to check it, right???
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 11-11-2004, 03:06 PM   #4
mkeefe
Registered User
 
Join Date: Sep 2004
Posts: 3
Default

I know in other programming languages you can "capture" the close command of the window. I am just curious if it will not run because of different browser types. I will test it out and let you know.

-matt
mkeefe is offline   Reply With Quote
Old 11-12-2004, 05:04 AM   #5
mkeefe
Registered User
 
Join Date: Sep 2004
Posts: 3
Default

Code:
<SCRIPT language="JavaScript">
<!--
function loadOut()
  {
  window.location="http://www.yoursite.com/loadout.php?sid=235346317";
  }
//-->
</SCRIPT>

<body onBeforeUnload="loadOut()">
Here is my result, it seems to work in all browsers.

Thank you everyone for your help.

EDIT: I am sorry for posting this in the Actionscript section. I originally thought it could be done in Flash.

-matt

Last edited by mkeefe; 11-12-2004 at 05:06 AM..
mkeefe is offline   Reply With Quote
Old 11-12-2004, 02:46 PM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
Default

Yup... That even checks the X button... Very nice...

PS> I'll move this thread to the HTML forum...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:51 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.