当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - How to detect Browser(Not window) close event

问题描述:

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? Thanks..!

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.

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: