473,486 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Capture click event of the "x" button on the browser window

Hi,

Need help on the following issue.

We need to clean up some session specific backend resource when a user ends
his session. We have a "Logoff" button on the pages that handles that. But
the problem is that sometimes the user still closing their browser window by
clicking on the "x" button of the window. This is quite a problem for us
because it will leave unreleased resource on the server for an unpredictable
period of time, depending the timeout setting on our client's web app.

Simply putting the logic in the window.onclose JavaScript wouldn't do the
job unless there is a way we can test and tell where the caller is from.
Because the clean-up work needed are different when exits from "x" than exits
from code.

Therefore, what I think we need is either an event handler that traps just
the "x" click event; or, in the window.onclose JavaScript, a way to test the
caller.

Can someone please help?

Thanks in advance!!!

Feng
Nov 19 '05 #1
1 2777
The only way to do it is with the onClose event handler of the window
object.

You could include in that event handler a form.submit() of an embedded form
that contains just one hidden form field that has a value of the sessionID.
So, when a user closes their browser, their session ID is passed to a
specific page that takes that value in and ends the session corresponding to
that session ID.

Be aware though, that users that correctly click your logout button would
still cause this code to run when they close their browser.

Most sites take care of this scenario by simply decreasing the
sessionTimeout to a value of 5 minutes or so.

"Feng" <Fe**@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi,

Need help on the following issue.

We need to clean up some session specific backend resource when a user
ends
his session. We have a "Logoff" button on the pages that handles that. But
the problem is that sometimes the user still closing their browser window
by
clicking on the "x" button of the window. This is quite a problem for us
because it will leave unreleased resource on the server for an
unpredictable
period of time, depending the timeout setting on our client's web app.

Simply putting the logic in the window.onclose JavaScript wouldn't do the
job unless there is a way we can test and tell where the caller is from.
Because the clean-up work needed are different when exits from "x" than
exits
from code.

Therefore, what I think we need is either an event handler that traps just
the "x" click event; or, in the window.onclose JavaScript, a way to test
the
caller.

Can someone please help?

Thanks in advance!!!

Feng

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2977
by: joe.osowski | last post by:
I've been staring at this a while, and I haven't had much luck with it. So I figure I'll try Usenet. No matter what I try, it seems the event.button property is always "0". Here is my test...
0
1598
by: [Yosi] | last post by:
I search solution for a little bit strange problem , I working on an application which includes a button. Click on this button will create number of threads each one execute deferent executable...
5
6799
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
1
972
by: bern11 | last post by:
I know how to open a video capture window in the Windows API, how do you do it in dot-net? Is it encapsulated in one of the name-spaces?
0
1360
by: radders | last post by:
Hi guys, What I'd like to do is place three edit boxes with three static text labels on a click button. This would let the user input RGB values to the three edit boxes and then click the...
12
65275
by: Thammarat charoenchai. | last post by:
Hi, I'm try to learn vb.net. in delphi have .click method for click button by coding. Can I do that with vb.net Thank you very much.
4
11054
by: nittin14 | last post by:
hi guys i m a beginner in Asp.net can u tell me that how to open page in new window after click button as well as i want to pass some data from this page. thanks
3
1761
by: Marco A. Cruz Quevedo | last post by:
Hi! I am a javascript newbie. I want to make a capture window in *standalone* (in a *.js file) javascript, much in the same way as the VBscript inputbox() function. I can make it inside a *.html...
5
1937
by: laziers | last post by:
Hi, anyone know how to write a single-cilick button? I use this: <asp:button id="ButtonAdd" runat="server" text="Anuluj" onclick="Click_ButtonAdd" /> if ( !isPostBack){...
1
1288
by: Henri.Chinasque | last post by:
Hi all, I've created a control, that when a user right clicks it, it will launch a form with some options. I would like this form to have typical "right click window" behaviour - when the user...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7305
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5427
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.