简体   繁体   中英

How to Differentiate between browser close and tab close

I want my application to execute some code when the browser is closed. My problem is beforeunload event that is called on both the browser close button and tab close. I don't need that code to be executed on tab close. Is there any way that we can execute that code on browser close not on tab close?

I have tried beforeunload event that is calling on browser close and tab close. I need to separate these close calls so that the same code shouldn't be executed on for browser close and tab close.

Unfortunately it is not possible to differentiate between these events. Refer to this thread Detect browser or tab closing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM