Detecting User Closing Window X button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nanajee
    New Member
    • Mar 2009
    • 1

    #1

    Detecting User Closing Window X button

    Hi,
    I want call a function when the user trying to close a browser by clicking on close button.
    for the above question i used onbeforeunload and onunload functions,these
    two functions working when i clicked on close button ,but my prob with onbeforeunload and onunload functions is ,when i tried to change the url then
    also the same functions calling so can any one give solution for me

    Thanks in advance
    Nanajee.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Unfortunately (of fortunately if you see it differently), it's not possible to determine if the current browser window is closed in a neat, cross-browser way. One or two hacks may work, but they wouldn't be reliable.

    One possibility, though, is to use a popup window and from the parent, you could check the window.closed property.

    Comment

    Working...