473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

using AJAX to detect Browser close

I see a lot of posts claiming that you can use AJAX or Javascript to run some
kind of "heartbeat" " server polling" that tells the server that the page is
still open. I need to know how exactly to do this (server side and client
side) or where I can find information on doing this. I want to run some code
after a page is closed and I don't want to wait for the session timeout.

if anyone has information please post explanations, code samples, or links.

thanks

Jun 15 '07 #1
2 2199
See the window.onclose event :

http://developer.mozilla.org/en/docs/DOM:window.onclose

Also don't rely on this too much (for example the browser could crash) so
make sure it doesn't make your application do something bad if this is not
called (such as not being able to create a file because the previous one was
not deleted).

--
Patrice

"Alhambra Eidos Kiquenet" <Al*******************@discussions.microsoft.com >
a écrit dans le message de news:
3A**********************************@microsoft.com...
>I see a lot of posts claiming that you can use AJAX or Javascript to run
some
kind of "heartbeat" " server polling" that tells the server that the page
is
still open. I need to know how exactly to do this (server side and client
side) or where I can find information on doing this. I want to run some
code
after a page is closed and I don't want to wait for the session timeout.

if anyone has information please post explanations, code samples, or
links.

thanks

Jun 15 '07 #2
Hi,

Alhambra Eidos Kiquenet wrote:
I see a lot of posts claiming that you can use AJAX or Javascript to run some
kind of "heartbeat" " server polling" that tells the server that the page is
still open. I need to know how exactly to do this (server side and client
side) or where I can find information on doing this. I want to run some code
after a page is closed and I don't want to wait for the session timeout.

if anyone has information please post explanations, code samples, or links.

thanks
Th<e "heartbeat" implementation relies on the fact that every request to
active content (which includes web services) extends the session. So if
you have a web client continuously "pinging" the web server using web
services, the session never dies. However, if the web client is closed,
the "pinging" stops, and 20 minutes later (or whatever the session
timeout is set to), the session expires.

We use this in our web application and it works fine. We managed to have
sessions lasting two weeks and more without too many side effects.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Jun 15 '07 #3

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

Similar topics

6
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
3
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
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...
1
by: jmdolinger | last post by:
Hi all, I'm a newbie to Atlas (and recently ASP.NET) after coming from a long Java background, also have done quite a bit with an Ajax.NET/ASP.NET 1.1 project, but it was basically all...
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
13
by: Marvin Zhang | last post by:
Hi, I'm not familiar with web programming, but I have a problem here. I have a page. When a user click one button on it, I will use AJAX to request a PHP script which will do a bunch of tasks,...
11
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,...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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
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...

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.