Reputation: 2744
I want to detect browser close (not the window(tab)) and run a script. I tried onunload
and onbeforeunload
but they are working fine with tab close but if I close entire browser nothing happens. How can I do this?
EDIT:
I just want to do a server side cleanup on any these kind of event. Is there any way to do that?
Upvotes: 1
Views: 2012
Reputation: 253308
Based on the question as asked, 'how can I [access the browser-close event]?' the only possible answer is: you can't; it's not possible. Nor, for security reasons, should it be.
I want to do a server side cleanup for any this kind of event. Is there any possible way to do it?
The only way I could think of, with JavaScript, is trigger an Ajax call to a server-side script notifying it of the close-event, using onunload
or onbeforeunload
, and having that script tidy up any sessions that might still be open.
Upvotes: 2