How to detect IE window close (X) action by user?

Discussion in 'ASP .Net' started by =?Utf-8?B?S3VtYXIuQS5QLlA=?=, Oct 16, 2007.

  1. =?Utf-8?B?S3VtYXIuQS5QLlA=?=, Oct 16, 2007
    #1
    1. Advertising

  2. "Kumar.A.P.P" <> wrote in message
    news:...


    This question comes up time and time again.

    Generally speaking, there is no way for the server to know if the client
    browser has been closed, or even if the client has navigated to another
    website.

    This is because of the fundamental architecture of the web.

    The server waits for an incoming HttpRequest.

    The server processes the incoming HttpRequest.

    The server sends back an HttpResponse.

    The server waits for an incoming HttpRequest. If no incoming HttpRequest
    arrives, there's nothing the server can do about it...

    There have been various possible solutions suggested, mainly to do with the
    <body onload> method, but none is satisfactory...

    Why do you need to know this anyway...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Oct 16, 2007
    #2
    1. Advertising

  3. =?Utf-8?B?S3VtYXIuQS5QLlA=?=

    bruce barker Guest

    in javascript catch the onbeforeunload or onunload event, and check the
    event x & y positions (they will be off srceen). its a hack.

    -- bruce (sqlwork.com)


    Kumar.A.P.P wrote:
    >
    > Kumar.A.P.P
    > Software Engineer, Infosys Technologies Limited.
    > http://techaid.wordpress.com/
    bruce barker, Oct 16, 2007
    #3
  4. As above, catch the body.unload event and fire a postback event from
    Javascript to tell the server the page is closing.

    The only draw back is that is will fire when the user closes the
    browser and when they move to a different page.


    Fran

    http://www.bluejumper.com
    BlueJumper.com, Oct 17, 2007
    #4
  5. "BlueJumper.com" <> wrote in message
    news:...

    > As above, catch the body.unload event and fire a postback event from
    > Javascript to tell the server the page is closing.
    >
    > The only draw back is that is will fire when the user closes the
    > browser and when they move to a different page.


    That's right - so not much use for any website which has more than one
    page...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Oct 17, 2007
    #5
  6. On Oct 17, 9:52 am, "Mark Rae [MVP]" <> wrote:
    > "BlueJumper.com" <> wrote in message
    >
    > news:...
    >
    > > As above, catch the body.unload event and fire a postback event from
    > > Javascript to tell the server the page is closing.

    >
    > > The only draw back is that is will fire when the user closes the
    > > browser and when they move to a different page.

    >
    > That's right - so not much use for any website which has more than one
    > page...
    >
    > --
    > Mark Rae
    > ASP.NET MVPhttp://www.markrae.net



    As you so eloquently pointed out, it depends why you need to do this!
    BlueJumper.com, Oct 17, 2007
    #6
    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. Replies:
    7
    Views:
    11,931
  2. Iñaki Baz Castillo
    Replies:
    7
    Views:
    843
    Iñaki Baz Castillo
    Jan 12, 2010
  3. Shang Wenbin

    close current window using window.close()

    Shang Wenbin, Sep 1, 2005, in forum: Javascript
    Replies:
    10
    Views:
    368
    Gérard Talbot
    Sep 2, 2005
  4. Replies:
    0
    Views:
    490
  5. Replies:
    4
    Views:
    244
Loading...

Share This Page