Detect Browser Close for Window with Multiple Tabs (IE7)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • peepio
    New Member
    • Mar 2010
    • 3

    Detect Browser Close for Window with Multiple Tabs (IE7)

    Hello,

    I need to detect when the red X button on the browser window is clicked then logoff the session. It works only when the browser has a single tab because it meets the condition window.event.cl ientY < 0. However, when there are multiple tabs and user needs to respond to "Do you want to close all tabs" alert, window.event.cl ientY is no longer negative. This is for IE 7. Any suggestions?

    Thank you.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    That's a bit of a hack.

    Can you not use a session timeout instead? E.g. 30 minutes of inactivity results in the session being invalidated.

    Comment

    • peepio
      New Member
      • Mar 2010
      • 3

      #3
      There's a session time limit but we also need to detect this event to logout the current user.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        One possibility is the onbeforeunload event, but that would fire for all unloads including reload and going back and forward.

        I'm still not sure why you'd want to log the user off when they close the window.

        Comment

        • peepio
          New Member
          • Mar 2010
          • 3

          #5
          acoder,

          I'm using the onbeforeunload event but as you've mentioned it is fired in all cases so I need some sort of condition to identify browser close action.

          The user needs to be logged out of the system otherwise the user won't be able to log back into the system until after the session has timed out.

          Comment

          Working...