473,503 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detect if browser closed

Can anybody tell me how to detect is the user has closed the browser

Thank you
Nov 19 '05 #1
7 2143
If this is during a request try IsClientConnected.

Else you have to callback the server when it happens (and in the case of a
client side crash or if JS is disabled etc..., you'll never know the browser
closed).

Generally I try to design for not having to care... (you may want to explain
what you want to do when the user closes the browser).

Patrice

--

"Chris" <cc*********@hotmail.com> a écrit dans le message de
news:%2***************@TK2MSFTNGP12.phx.gbl...
Can anybody tell me how to detect is the user has closed the browser

Thank you

Nov 19 '05 #2
Hi,
If Javascript is enabled in the client side, then you can use window.Closed
property to check whether the window is close.
For eg in Child window to check the parent window is closed you can use
if(window.parent.closed)
// do some thing

Regards,
Sambathraj
"Chris" <cc*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Can anybody tell me how to detect is the user has closed the browser

Thank you

Nov 19 '05 #3
Ok what needs to have happen.
when a user edits a record I am locking the record by a bit field.
So if the user clicks the x on that edit screen I need detect that and
unlock the record in the database.

I am storing the locking by user session.sessionID.
If you know of a way to get all session.sessionID's that would work for me
too. I can run a check on that instead. Which is what I want to do.

Thanks

"Chris" <cc*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Can anybody tell me how to detect is the user has closed the browser

Thank you

Nov 19 '05 #4
Hi Chris,

You can't tell when the browser has closed, as HTTP is stateless. That is
why Sessions time out, and why there is a Session_End event handler in your
global class. Assuming that your app can wait 20 minutes to perform this
cleanup task, that's the place to do it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Chris" <cc*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Ok what needs to have happen.
when a user edits a record I am locking the record by a bit field.
So if the user clicks the x on that edit screen I need detect that and
unlock the record in the database.

I am storing the locking by user session.sessionID.
If you know of a way to get all session.sessionID's that would work for me
too. I can run a check on that instead. Which is what I want to do.

Thanks

"Chris" <cc*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Can anybody tell me how to detect is the user has closed the browser

Thank you


Nov 19 '05 #5
Are you sure you need exclusive locking ? Did you checked the optimistic
approach ? What is the probability to have multiple people editing the same
record at the same time ?
You could also keep a datetime instead of just a bit field. It would allow
to have a safety mecanism so that a long running lock could be discarded...

If you really need you could trap onbeforeunload or onclose or a similar
client side event to call a server side page to unlock the record.

Patrice

--

"Chris" <cc*********@hotmail.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP10.phx.gbl...
Ok what needs to have happen.
when a user edits a record I am locking the record by a bit field.
So if the user clicks the x on that edit screen I need detect that and
unlock the record in the database.

I am storing the locking by user session.sessionID.
If you know of a way to get all session.sessionID's that would work for me
too. I can run a check on that instead. Which is what I want to do.

Thanks

"Chris" <cc*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Can anybody tell me how to detect is the user has closed the browser

Thank you


Nov 19 '05 #6
You may be able to take advantage of the client side OnClose event.
Here's more info:
http://www.mozilla.org/docs/dom/domr...dow_ref56.html

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Chris" <cc*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Can anybody tell me how to detect is the user has closed the browser

Thank you

Nov 19 '05 #7
Well I have gone another route. Just to let you all know.
First off thanks for the info

I am now using the system.web.cacheing.cache
I store a dataset in there with a recordid and a recordtype

now if the user closes his brower it will take about 5 mins for the
application to unlock that record in the cache.
"Chris" <cc*********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Can anybody tell me how to detect is the user has closed the browser

Thank you

Nov 19 '05 #8

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

Similar topics

6
5208
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
2
2235
by: NWx | last post by:
Hi, I have the following question: I have an app that uses user login/logout to identify users When user logon, I register logon time in a session variable When user logoff using the logout...
3
4250
by: Lord2702 | last post by:
Sat. Oct. 30, 2004 3:25 PM PT I want to detect, if user has close the browser, (after logging to my site), that user has closed the browser. How to achieve it ? I want to know this close action...
8
17361
by: Luke Matuszewski | last post by:
I have read all posts about how to detect that url have changed to new page and trigger the event handler then eg. function aidLogout(evt) { if(evt) { /* maybe via analyse of evt object i can...
7
4976
by: tarun.kataria | last post by:
Hi All, Is there any way to detect that the user is trying to Xout the browser window instead of hitting a button. Because in my application I want to make it sure that they dont do it either...
4
4020
by: Dst | last post by:
This is what i'm trying to do: I'm porting a windows app to a web app. I have a webform which will edit some data stored in a database. The data needs to be locked in the database, while editing....
11
4106
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I have an aplication web asp.net 2.0 and I am Trying to detect the close event in browser, which is the best performance for do this ? What's up with Alt+F4, Refresh, user clicks X,...
4
7899
by: nrocha | last post by:
Hello, I've been trying to detect when a user closes a page or navigates away from it. This is part of a solution for locking pages (that is, if a user enters a page, no one else can enter it...
5
2913
by: =?Utf-8?B?QW5keQ==?= | last post by:
As per the question really. Not trying to stop them leaving, but just detect WHEN they leave the site
0
7201
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
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
7328
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...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4672
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
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
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.