Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Detect if browser closed

Reply
Thread Tools

Detect if browser closed

 
 
Chris
Guest
Posts: n/a
 
      04-27-2005
Can anybody tell me how to detect is the user has closed the browser

Thank you


 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      04-27-2005
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" <> a écrit dans le message de
news:%...
> Can anybody tell me how to detect is the user has closed the browser
>
> Thank you
>
>



 
Reply With Quote
 
 
 
 
Sambathraj
Guest
Posts: n/a
 
      04-27-2005
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" <> wrote in message
news:%...
> Can anybody tell me how to detect is the user has closed the browser
>
> Thank you
>
>



 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      04-27-2005
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" <> wrote in message
news:%...
> Can anybody tell me how to detect is the user has closed the browser
>
> Thank you
>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      04-27-2005
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" <> wrote in message
news:%...
> 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" <> wrote in message
> news:%...
>> Can anybody tell me how to detect is the user has closed the browser
>>
>> Thank you
>>
>>

>
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      04-27-2005
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" <> a écrit dans le message de
news:%...
> 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" <> wrote in message
> news:%...
> > Can anybody tell me how to detect is the user has closed the browser
> >
> > Thank you
> >
> >

>
>



 
Reply With Quote
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      04-27-2005
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" <> wrote in message
news:%...
> Can anybody tell me how to detect is the user has closed the browser
>
> Thank you
>
>



 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      04-27-2005
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" <> wrote in message
news:%...
> Can anybody tell me how to detect is the user has closed the browser
>
> Thank you
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detect on the server when window is being closed on the server news.microsoft.com ASP .Net 2 12-17-2005 11:47 PM
Detect TKinter window being closed? Glen Python 3 12-02-2005 05:09 PM
Detect moment when user closed session NWx ASP .Net 2 02-03-2004 03:20 PM
Help: How to detect if the browser is closed? hb ASP .Net 6 11-19-2003 04:57 PM
Opera - .closed not accessible if window is closed? Matt Kruse Javascript 5 09-09-2003 01:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57