Catching a tab close event in web browser?

前端 未结 7 2347
我寻月下人不归
我寻月下人不归 2020-12-18 08:45

Is there any way of knowing if the user closes a tab in a web browser? Specifically IE7, but also FireFox and others as well. I would like to be able to handle this situatio

7条回答
  •  一向
    一向 (楼主)
    2020-12-18 09:31

    Attach an "onbeforeunload" event. It can execute code just before the browser/tab closes.

提交回复
热议问题