| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Sep 2004
Posts: 3
|
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 |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Nov 2004
Posts: 163
|
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 |
|
|
|
|
|
|
|
|
#3 |
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
|
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...
|
|
|
|
|
|
#4 |
|
Registered User
Join Date: Sep 2004
Posts: 3
|
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 |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Sep 2004
Posts: 3
|
Code:
<SCRIPT language="JavaScript">
<!--
function loadOut()
{
window.location="http://www.yoursite.com/loadout.php?sid=235346317";
}
//-->
</SCRIPT>
<body onBeforeUnload="loadOut()">
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.. |
|
|
|
|
|
#6 |
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
|
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...
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|