简体   繁体   中英

Can we capture the same browser closing event without using “onunload”

Actually using the window.close , we can control whether browser is closed or not, but it works only for pop-ups created by the browser.

So, are there any ways to listen to the closing event of the browser without using onunload ? Because we don't want things to be executed when back , refresh or forward actions occur.

Please also reply if you know specifics regarding Firefox.

Thanks in advance!

You are trying to manipulate the EXPECTED behaviour of the browser, essentially taking away people's ability to navigate. Fortunately browser developers were smart enough to disallow this - so the answer is NO.

我还想以与onunload不同的方式关闭浏览器/选项卡,因为在这种情况下我想执行一些验证,但不是页面中存在的所有onunload可能性,这对我来说是一个有效的用例。

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