Anyway, to catch the closure of the web browser?

Two years ago, I had to mask the closure of a web browser as javascript events for a web application. At the time I discovered that this did not work, it worked for all browsers. IE had an event that I could use, but it was IE specific. I looked into another job around, for example, due to the heart rate of pinging a server, but at that time I did not like any of them.

Is there currently an opportunity to block the closing of a web browser? Thanks!

+4
source share
2 answers

you can use

window.onbeforeunload 

javascript to do this, although this trap is more than just closing the browser. This event will also be fired every time someone tries to go to another page, refreshes the current page, etc. This is useful if you are trying to do something like warning people about unsaved changes before they leave the current page.

+9
source

onunload works in IE and Firefox.

+2
source

All Articles