Link to home
Start Free TrialLog in
Avatar of jason101799
jason101799

asked on

How to detect a window being close????

Experts,

I wanted to know how to detect a user closing an existing window. This window contains frames. Actually I am working on the security part, whenever a user login I will set an indicator to 1 in the database so that the user cannot login again from another browser. When the user click logout or session timeout I will set this indicator to 0 so that he can login again later. But the biggest problem is how to set the indicator to 0 when a user closes the window?????

I will be grateful if you can provide expert advice.



Cheers
Jason
ASKER CERTIFIED SOLUTION
Avatar of a.marsh
a.marsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jason101799
jason101799

ASKER

Ant,

I am trying to understand your suggestion. Can you elaborate coz I am lost. I am kinda slow :)

My concern is whenever a user click on closes the window by clicking the "x" at the top right corner of the browser I will call a function (ASP codes) to update my login indicator to "N". At least the user can login in again later.

One more question, what if the modem line got cut off and the user reboots the PC?? Can I consider the window being closed?? Will the Web Server knows that this session is ended??

Thanks

Cheers
Jason
You can open a new window. Once the x-button has been clicked, you will go to the page that will set your counter to zero or that will abandon the session(ASP page)....


<html>
<script>
 function gio()
 {
 alert('This will bring you to the logout page!');
 window.open('ASP page');
 }
</script>
<body onunload="gio()">
 Code....
</body>
</html>

...if the modem is has been interupted then you'll have a problem...
You can open a new window. Once the x-button has been clicked, you will go to the page that will set your counter to zero or that will abandon the session(ASP page)....


<html>
<script>
 function gio()
 {
 alert('This will bring you to the logout page!');
 window.open('ASP page');
 }
</script>
<body onunload="gio()">
 Code....
</body>
</html>

...if the modem is interupted, then you'll have a problem...
You can open a new window. Once the x-button has been clicked, you will go to the page that will set
your counter to zero or that will abandon the session(ASP page)....


<html>
<script>
function gio()
{
alert('This will bring you to the logout page!');
window.open('ASP page');
}
</script>
<body onunload="gio()">
Code....
</body>
</html>

...if the modem is has been interupted then you'll have a problem...
virus05 - please read the EE guidelines on proposing answers.

Feel free to reject the answer jason, in order to unlock the question and allow a greater level of feedback from experts.

Ant
Please return and update/finalize this question, it is ancient.

Expert input welcome if I must decide the outcome.

EE Moderator
It seems I never came back and responded to the last question posted by jason - sorry about that.

Not sure if jason still needs help with this.....

Ant
Admin notified of User neglect. Force-accepted by
Netminder
Community Support Moderator
Experts Exchange