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?
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.
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
onunloadoronbeforeunload, and having that script tidy up any sessions that might still be open.