Is there any cross-browser JavaScript/jQuery code to detect if the browser or a browser tab is being closed, but not due to a link being clicked?
21条回答 默认 最新
weixin_33704591 2010-10-08 08:39关注If I get you correctly, you want to know when a tab/window is effectively closed. Well, AFAIK the only way in
Javascriptto detect that kind of stuffs areonunload&onbeforeunloadevents.Unfortunately (or fortunately?), those events are also fired when you leave a site over a
linkor your browsers back button. So this is the best answer I can give, I don't think you can natively detect a pureclosein Javascript. Correct me if I'm wrong here.解决 无用评论 打赏 举报