If I get you correctly, you want to know when a tab/window is effectively closed.
(如果我正确地理解了您,您想知道何时有效关闭标签页/窗口。)
Well, AFAIK the only way in Javascript
to detect that kind of stuffs are onunload
& onbeforeunload
events.(好吧,AFAIK是Javascript
中检测此类内容的唯一方法是onunload
和onbeforeunload
事件。)
Unfortunately (or fortunately?), those events are also fired when you leave a site over a link
or your browsers back button.
(不幸的是(或幸运的是?),当您通过link
或浏览器的后退按钮离开站点时,也会触发这些事件。)
So this is the best answer I can give, I don't think you can natively detect a pure close
in Javascript.(因此,这是我能给出的最佳答案,我认为您无法自然地在Javascript中检测到纯close
。)
Correct me if I'm wrong here.(如果我错了,请纠正我。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…