You should return something from beforeunload
.
The confirm
will be ignored
Since 25 May 2011, the HTML5 specification states that calls to window.showModalDialog(), window.alert(), window.confirm() and window.prompt() methods may be ignored during this event.
window.onbeforeunload = function() {
return 'Date will be lost: are you sure?'; //<= here
}
If you don't return something, the actions within the handler function are executed before the page unloads.