Gossamer Forum
Home : General : Internet Technologies :

Javascript Redirect on Window Close

Quote Reply
Javascript Redirect on Window Close
Here's the scenario. I have a site which a user must log on to. User name and password are validated in a mysql data base. Also in the mysql data base are two fields called concurrent_users which keeps track of if the user is logged on more than once simultaneously. When a user logs on, concurrent_users is increased by one and likewise, when they click on Log Off, concurrent_users is decreased by one. Now enter the problem. What if a user just clicks on X and closes the window?

I tried using <body onUnload="window.location.href='http://www.mysite.com'"> which would take them to a page with a script which handles the mysql update. However, with this body tag, every time the browser changes to a new url, it is referred to the page listed in onUnload. I thought onUnload meant when the window closes. Is there a different syntax for closing a window?

Long story short, how do I redirect a user to a new url when the click on the X in their browser window?

Thanks in advance for the suggestions!
Subject Author Views Date
Thread Javascript Redirect on Window Close Lee 3961 Apr 4, 2004, 12:52 PM
Post Re: [Lee] Javascript Redirect on Window Close
Watts 3774 Apr 5, 2004, 10:34 AM