473,322 Members | 1,714 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,322 software developers and data experts.

Detecting user leaving page

Okay, I feel like this is probably a stupid question, but...

I have accessed sites that are pushing some scam that, when you go to
leave the page it will pop up a box saying, "No, don't go, let our
live agent talk you into buying our junk."

My question is, what event do they use to tell that you are leaving
the page? Looking through the events available in the Page class, I
see a lot that take place when the page is initiated, but nothing that
is triggered when the user leaves.

What am I missing?

Thanks for your help.
Aug 5 '08 #1
4 2587
They use a standard html event : Body_OnUnload.

http://www.htmlcodetutorial.com/docu..._onUnload.html

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"daveh551" <ge****@gmail.comwrote in message news:20**********************************@x35g2000 hsb.googlegroups.com...
Okay, I feel like this is probably a stupid question, but...

I have accessed sites that are pushing some scam that, when you go to
leave the page it will pop up a box saying, "No, don't go, let our
live agent talk you into buying our junk."

My question is, what event do they use to tell that you are leaving
the page? Looking through the events available in the Page class, I
see a lot that take place when the page is initiated, but nothing that
is triggered when the user leaves.

What am I missing?

Thanks for your help.

Aug 5 '08 #2
It's a client side event, not a server side (ASP .NET) event. It's simply
the unload event.
"daveh551" <ge****@gmail.comwrote in message
news:20**********************************@x35g2000 hsb.googlegroups.com...
Okay, I feel like this is probably a stupid question, but...

I have accessed sites that are pushing some scam that, when you go to
leave the page it will pop up a box saying, "No, don't go, let our
live agent talk you into buying our junk."

My question is, what event do they use to tell that you are leaving
the page? Looking through the events available in the Page class, I
see a lot that take place when the page is initiated, but nothing that
is triggered when the user leaves.

What am I missing?

Thanks for your help.

Aug 5 '08 #3
On Aug 4, 10:13 pm, "Scott M." <s-...@nospam.nospamwrote:
It's a client side event, not a server side (ASP .NET) event. It's simply
the unload event.

"daveh551" <gee...@gmail.comwrote in message

news:20**********************************@x35g2000 hsb.googlegroups.com...
Okay, I feel like this is probably a stupid question, but...
I have accessed sites that are pushing some scam that, when you go to
leave the page it will pop up a box saying, "No, don't go, let our
live agent talk you into buying our junk."
My question is, what event do they use to tell that you are leaving
the page? Looking through the events available in the Page class, I
see a lot that take place when the page is initiated, but nothing that
is triggered when the user leaves.
What am I missing?
Thanks for your help.
Thanks, both of you. That makes sense.

Follow on question, and dont feel compelled to answer it because Im
sure I can dig a little and find the answer on my own, but what kind
of javascript code would I write to reflect that event back to the
server to do something with there?(I.e, I want to record the time the
user spent on a page in a database for statistical analysis, so I need
to record when they leave.)
Aug 6 '08 #4
You could place an HTML hidden form field into the page and then update that
field's value with the current time on the page's unload event.
"daveh551" <ge****@gmail.comwrote in message
news:42**********************************@34g2000h sf.googlegroups.com...
On Aug 4, 10:13 pm, "Scott M." <s-...@nospam.nospamwrote:
>It's a client side event, not a server side (ASP .NET) event. It's
simply
the unload event.

"daveh551" <gee...@gmail.comwrote in message

news:20**********************************@x35g200 0hsb.googlegroups.com...
Okay, I feel like this is probably a stupid question, but...
I have accessed sites that are pushing some scam that, when you go to
leave the page it will pop up a box saying, "No, don't go, let our
live agent talk you into buying our junk."
My question is, what event do they use to tell that you are leaving
the page? Looking through the events available in the Page class, I
see a lot that take place when the page is initiated, but nothing that
is triggered when the user leaves.
What am I missing?
Thanks for your help.

Thanks, both of you. That makes sense.

Follow on question, and dont feel compelled to answer it because Im
sure I can dig a little and find the answer on my own, but what kind
of javascript code would I write to reflect that event back to the
server to do something with there?(I.e, I want to record the time the
user spent on a page in a database for statistical analysis, so I need
to record when they leave.)

Aug 6 '08 #5

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

Similar topics

0
by: Erik Bethke | last post by:
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the...
1
by: Erik Bethke | last post by:
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the...
2
by: G | last post by:
Hello, I want to launch a pop-under survey when a user leaves my page by closing the window, but NOT by leaving the page via a hyperlink or form submission. Is this easy to accomplish with...
3
by: Csaba Gabor | last post by:
If I detect an empty textbox, I fill it with a value ('Dad'). If I do this twice, the second time around IE 6 fails to notice that I've cleared the textbox again, thus leaving the textbox cleared....
2
by: Kiran | last post by:
Hi all, Can anybody let me know how to detect when my user clicks the X button on the window. I used unload event it did not work(on IE). My web page is a .asp page which reloads itself when...
1
by: Luthor | last post by:
Hi, Say I'm on the site www.xyz.com and on a certain page if the user leaves the domain xyz.com, I have a popup cme up w/ stuff. I don't need to know what the new domain is, I just want to know...
11
by: Dag Sunde | last post by:
We have this web-app that requires Javascript to be enabled in the UA (this is okay'ed by our customer). Now I want to make a "pre" page before the login screen, informing the user that he/she...
7
by: jab3 | last post by:
Hello. I'm wondering if someone can answer something I'm sure has been answered a thousand times before. I am apparently just too dumb to find the answer. :) I've found information about the...
8
by: pamelafluente | last post by:
I am reposting hoping better luck :) I can't achieve this simple thing: I have an animated gif in an image control (ImageProgress1). The image visibility is set to false. I want that when the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.