Detecting user leaving page

Discussion in 'ASP .Net' started by daveh551, Aug 5, 2008.

  1. daveh551

    daveh551 Guest

    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.
    daveh551, Aug 5, 2008
    #1
    1. Advertising

  2. They use a standard html event : Body_OnUnload.

    http://www.htmlcodetutorial.com/document/_BODY_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" <> wrote in message news:...
    > 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.
    Juan T. Llibre, Aug 5, 2008
    #2
    1. Advertising

  3. daveh551

    Scott M. Guest

    It's a client side event, not a server side (ASP .NET) event. It's simply
    the unload event.


    "daveh551" <> wrote in message
    news:...
    > 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.
    Scott M., Aug 5, 2008
    #3
  4. daveh551

    daveh551 Guest

    On Aug 4, 10:13 pm, "Scott M." <> wrote:
    > It's a client side event, not a server side (ASP .NET) event. It's simply
    > the unload event.
    >
    > "daveh551" <> wrote in message
    >
    > news:...
    >
    > > 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.)
    daveh551, Aug 6, 2008
    #4
  5. daveh551

    Scott M. Guest

    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" <> wrote in message
    news:...
    > On Aug 4, 10:13 pm, "Scott M." <> wrote:
    >> It's a client side event, not a server side (ASP .NET) event. It's
    >> simply
    >> the unload event.
    >>
    >> "daveh551" <> wrote in message
    >>
    >> news:...
    >>
    >> > 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.)
    Scott M., Aug 6, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sacha Korell
    Replies:
    6
    Views:
    3,026
    MasterGaurav
    Mar 9, 2005
  2. Replies:
    7
    Views:
    25,895
    rohit.net100
    Feb 28, 2011
  3. Chris Roden
    Replies:
    4
    Views:
    564
    Mark Rae [MVP]
    Dec 13, 2007
  4. Zvonko

    Capturing event user leaving page

    Zvonko, Sep 2, 2005, in forum: Javascript
    Replies:
    8
    Views:
    211
    ExGuardianReader
    Sep 10, 2005
  5. koruyucu
    Replies:
    2
    Views:
    153
    Thiago Macedo
    Jul 30, 2008
Loading...

Share This Page