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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to call a function when user closes window

    I am writing a code which requires state maintainance like login. Here problem is that many of the users directly close the window without logout. This gives a problem that state maintaining variables stored in server database does not get deleted. Is there any JavaScript which could execute a function when user closes window. I have tried <body onUnload="function()"> but it will get executed when user presses 'Refresh' button. I want to catch the event of closing the window so that the session can be closed.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    You are no going to find a solution since different actions will cause this to fire. You can try using onbeforeunload, but that will lead to issues too.

    You should not be relying on clientside code, you should be relying on your session timeout on the server to clean things up.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to use timeout

    I am new to web programming. I use Perl for server side programming. How can I use timeout. Kindly tell me more about this and also the code or atleast some referance.


  •  

    Posting Permissions

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