GC_
GC_

Reputation: 1673

Is there a workaround for Firefox not calling onunload when a window is closed?

As some of you know Firefox does not call onunload in if the window or tab is closed. Do you know of any sort of work around?

Basically, I need to know that user is done with the window, so I can free a lock. Do you all have any suggestions?

I have heard robust code should not use onunload. Is there some obvious alternative?

Upvotes: 1

Views: 310

Answers (1)

Michael Lorton
Michael Lorton

Reputation: 44386

If your lock is on the server, make the lock time out after (say) 30 seconds and have a function on the window automatically renew the lock every 25 seconds. Call the function from a setInterval. When the window is closed, the interval is canceled and the lock will timeout 15 seconds later (on average). Crude but effective.

Upvotes: 2

Related Questions