Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    gjc
    gjc is offline
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Capturing browser close

    Anyone know how to capture the event fired when the user closes the browser using the "X" button?

    I have a web application running in C# that locks objects in a Db but needs to unlock these objects if a user exits the browser.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    better off put a timer on the locked objects. You can never predict the manner in which the user exits your application for example, what if their computer crashes or there is power outage...
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I recently learned of 'onbeforeunload' in this forum. Used the the body tag detects even the X method of closing.

    <body onbeforeunload="callfunction()"> will call your function before the user exits.

    ROBB

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This subject has been beaten to death in many threads like this one on many forums like this one. Let me summarize for you:

    There is no way to determine the difference between the browser closing and another action that triggers the unloading events. You cannot single-out browser closures from other types of unloading.

    In short, what you ask, cannot be done.

    BTW, onbeforeunload is IE-only -- even then -- it still fires at every page unloading and not just browser closures.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •