Capturing result of window.onbeforeunload confirmation dialog

You can have the exit confirmation using window.onbeforeunload but there isn’t a way to find out which button the user clicked on.

To quote an earlier response from jvenema from this thread:

The primary purpose for the
beforeunload is for things like
allowing the users the option to save
changes before their changes are lost.

Besides, if your users are leaving,
it’s already too late […]

Leave a Comment