Firefox Execute Javascript Code when user closes window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsherp
    New Member
    • May 2007
    • 34

    Firefox Execute Javascript Code when user closes window

    How does one execute code when the user closes the browers window by clicking on the top right corner [x]. I need to log out user and do a database write when the user closes the brower. I do these to clean up the database when the user exits before actually logging out.

    I was told to user pageX, but does not seem to work either. Again, I am having trouble with firefox.

    Thanks.
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    Originally posted by gsherp
    How does one execute code when the user closes the browers window by clicking on the top right corner [x].
    Have you tried triggering on the window.onunload event?



    Originally posted by gsherp
    I need to log out user
    Your application/web server should automatically being doing this after x number of minutes of inactivity.



    Originally posted by gsherp
    I need to log out user and do a database write when the user closes the brower. I do these to clean up the database when the user exits before actually logging out.
    This does not sound like a very good design. It does not take into account things like the user going to an other site after going to yours. And are you saying you have hanging database transactions that do not complete until they logout? If not what is it you have to "clean up"?

    Comment

    • gsherp
      New Member
      • May 2007
      • 34

      #3
      I tried using the onunload, but it will trigger after the user navigates way from the page...in my application the user goes from page to page looking at customer data.
      So that is why i need to determine if the onunload occurred if the user clicked the windows [x] button.

      As far as cleaning up on log out...

      Customer Data is locked by a flag in the database when the user checks out for editing...there fore other users can only veiw and not edit it at the same time.

      when the user is done editting the the flag is cleared, so other users can edit the customer data.

      Comment

      Working...