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

Detecting user leaving page

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.