DOM Window unload event, is it reliable?

后端 未结 2 1019
借酒劲吻你
借酒劲吻你 2020-12-10 02:31

Can I rely on the window unload event to be triggered when a user closes a tab/window/browser?

Edit:

Found a list of what triggers the unload event in IE. ht

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 02:57

    You will likely want to use the "onbeforeunload" event too, it provides more control than the "onunload" event.

    That said, be aware that: Opera doesn’t fire the unload event when the browser refreshes the page, or uses the back/forward buttons to browse off of the page. What’s worse, Opera never fires the onbeforeunload event. Thus if you are supporting Opera - be aware of these issues.

提交回复
热议问题