By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,734 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,734 IT Pros & Developers. It's quick & easy.

Tracking users when browser is closing

P: n/a
Hi all,

I have an important question to ask about how to trap events when the user
close the browser window.
I'm a ASP programmer and I have s MSSQL database with a user table where I'm able to track if the user is logged in or not.
However this is not easy to track if the user close the browserwindow without using the logout button. I have tried putting in code in Session_onend, but it doesn't seem to run if the browser is closed. Eg. tracking visitors in a application variable in Session_OnStart and Session_OnEnd.
So if there is any solutions on a safe way on logging users in a database, please let me know!
In advance thank you very much!!

Kind regards,

Jon Haakon

--
------------------------------
Jon Haakon Ariansen
System Consultant
Jul 19 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
use an html onclose event to launch another page that will briefly pop-up,
make the necessary tweaks to your data and them close itself... of course
this is defeated if they have a pop-up killr but you are no further back.

"hawkon" <ha****@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
Hi all,

I have an important question to ask about how to trap events when the user
close the browser window.
I'm a ASP programmer and I have s MSSQL database with a user table where I'm able to track if the user is logged in or not. However this is not easy to track if the user close the browserwindow without using the logout button. I have tried putting in code in
Session_onend, but it doesn't seem to run if the browser is closed. Eg.
tracking visitors in a application variable in Session_OnStart and
Session_OnEnd. So if there is any solutions on a safe way on logging users in a database, please let me know! In advance thank you very much!!

Kind regards,

Jon Haakon

--
------------------------------
Jon Haakon Ariansen
System Consultant

Jul 19 '05 #2

P: n/a
hawkon wrote:
Hi all,

I have an important question to ask about how to trap events when the
user
close the browser window.
I'm a ASP programmer and I have s MSSQL database with a user table
where I'm able to track if the user is logged in or not.
However this is not easy to track if the user close the browserwindow
without using the logout button. I have tried putting in code in
Session_onend, but it doesn't seem to run if the browser is closed.
Eg. tracking visitors in a application variable in Session_OnStart
and Session_OnEnd. So if there is any solutions on a safe way on
logging users in a database, please let me know!
In advance thank you very much!!

Kind regards,

Jon Haakon


It is unlikely that you will get much help with client-side code and events
in an asp group (asp is server-side technology). While many here do have
knowledge about client-side code, they are unlikely to answer such questions
here because their desire is to come to this group to discuss asp. You will
have better success getting a helpful response on one of the dhtml or
scripting newsgroups.

That said, the closing of the browser window does not raise any trappable
events. The window_onclose event does not fire when the browser is closed.

Sorry.
Aaron has an article on his site about tracking database use that you may
find helpful: http://www.aspfaq.com/show.asp?id=2491

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #3

P: n/a
Sounds very nice - however I've been looking for html close event without any luck.
So my question would be - what kind of close event can I use that is supported by the main browsers like MSIE, Netscape and Opera??

In advance thank you very much!

Kind regards,

Jon Haakon
--
------------------------------
Jon Haakon Ariansen
System Consultant
"UncleWobbly" wrote:
use an html onclose event to launch another page that will briefly pop-up,
make the necessary tweaks to your data and them close itself... of course
this is defeated if they have a pop-up killr but you are no further back.

"hawkon" <ha****@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
Hi all,

I have an important question to ask about how to trap events when the user
close the browser window.
I'm a ASP programmer and I have s MSSQL database with a user table where

I'm able to track if the user is logged in or not.
However this is not easy to track if the user close the browserwindow

without using the logout button. I have tried putting in code in
Session_onend, but it doesn't seem to run if the browser is closed. Eg.
tracking visitors in a application variable in Session_OnStart and
Session_OnEnd.
So if there is any solutions on a safe way on logging users in a database,

please let me know!
In advance thank you very much!!

Kind regards,

Jon Haakon

--
------------------------------
Jon Haakon Ariansen
System Consultant


Jul 19 '05 #4

P: n/a
Hi,

Sounds very nice - however I've been looking for html close event without any luck.


No really an html event, but rather a Javascript event.

<body onClose="do_your_thing()">

Yan

Jul 19 '05 #5

P: n/a
Yan Roosens wrote:
Hi,

Sounds very nice - however I've been looking for html close event
without any luck.
No really an html event, but rather a Javascript event.

Just to be picky, it's not a Javascript event. It's a DOM event. Document
Object Model. Totally separate from Javascript, although it is usable by
Javascript as well as vbscript.

<body onClose="do_your_thing()">

I've found this to be unreliable when attempting to catch browser closes.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #6

P: n/a
Jon,

I am having that exact same issue. I am desperately trying to figure it out, as this problem is causing a delay in the development of the project I am working on. If you (or anyone else for that matter) find a solution, please don't hesitate to email it to me. Likewise, should I solve this dilemma, I will post it immediately as well as email it to everyone in this thread that has a readable email address.

Thanks in advance,
--------------------------
Rob Davidson
Software Engineer
PacificTec, Inc.
************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Jul 19 '05 #7

P: n/a
There is no solution. You simply can not do it. That is why a stateless "web
application" is not the proper solution for every situation.

--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com

"Robert Davidson" <ro***@pacifictec.com> wrote in message
news:O$**************@TK2MSFTNGP12.phx.gbl...
Jon,

I am having that exact same issue. I am desperately trying to figure it out, as this problem is causing a delay in the development of the project I
am working on. If you (or anyone else for that matter) find a solution,
please don't hesitate to email it to me. Likewise, should I solve this
dilemma, I will post it immediately as well as email it to everyone in this
thread that has a readable email address.
Thanks in advance,
--------------------------
Rob Davidson
Software Engineer
PacificTec, Inc.
************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &

ASP.NET resources...
Jul 19 '05 #8

P: n/a
I just finished up a feature like this on my community website. My
solution was to use an IFrame with an ASP page that I called
WhosOnline.asp. This is a self refreshing page that refreshes every 30
seconds.

The page executes a stored procedure on SQL Server that modifies and
reads a table called WHOS_ONLINE_T. This table only has two fields
(member_id and date_visited). Basically what the procedure does is
deletes any records in which the date visited is older than 35 seconds,
plugs in the members id and date visited (or updates the record if the
member is already present in the table with the current date/time). Then
the proc returns all records from the table.

It works beautifully and as a result the data in the table is only 30
seconds stale at most. Not bad for given that we are in a stateless
environment.

If you are interested, email me and I can give you the specs. It tooke
me less than an hour to completely code.

Alex Kail

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #9

P: n/a
"Alex Kail" <ka***@hotmail.com> wrote in message
news:eU*************@TK2MSFTNGP12.phx.gbl...
| I just finished up a feature like this on my community website. My
| solution was to use an IFrame with an ASP page that I called
| WhosOnline.asp. This is a self refreshing page that refreshes every 30
| seconds.
|
| The page executes a stored procedure on SQL Server that modifies and
| reads a table called WHOS_ONLINE_T. This table only has two fields
| (member_id and date_visited). Basically what the procedure does is
| deletes any records in which the date visited is older than 35 seconds,
| plugs in the members id and date visited (or updates the record if the
| member is already present in the table with the current date/time). Then
| the proc returns all records from the table.
|
| It works beautifully and as a result the data in the table is only 30
| seconds stale at most. Not bad for given that we are in a stateless
| environment.
|
| If you are interested, email me and I can give you the specs. It tooke
| me less than an hour to completely code.
|
| Alex Kail
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!

This sounds like a very good piece of code, but how compatible is it? Does
it work with browsers like firefox / mozilla / opera / crazy browser /
netscape / WebTV. I don't want to start a flame war, but isn't the whole
point behind development to be able to reach as many clients as possible? I
know quite a while ago iFrame was limited to IE only, so my question is,
would it be an acurate measurement tool if you have users using these other
browsers? Most of my sites are does not limit what browser can be used, and
it would be nice to know your code is compatible :)

--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
Jul 19 '05 #10

P: n/a
I know this works in IE 6 and Netscape 7.02. No problems that I have
seen. I have all flavors accessing the site, including a WebTV user,
1100 all together and I haven't heard anyone scream.

Alex

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #11

P: n/a
Wow, that's quite remarkable. Would you mind sharing the code? :)

--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
"Alex Kail" <ka***@hotmail.com> wrote in message
news:eR**************@tk2msftngp13.phx.gbl...
| I know this works in IE 6 and Netscape 7.02. No problems that I have
| seen. I have all flavors accessing the site, including a WebTV user,
| 1100 all together and I haven't heard anyone scream.
|
| Alex
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.