I have problem with return confirm in Chrome. In Firefox it is ok.
window.onbeforeunload = function() {
var result = confirm('Really?');
if(result) {
console.log('Do something');
}
}
Any ideas? Thanks!
I have problem with return confirm in Chrome. In Firefox it is ok.
window.onbeforeunload = function() {
var result = confirm('Really?');
if(result) {
console.log('Do something');
}
}
Any ideas? Thanks!
You should return something from
beforeunload
.The
confirm
will be ignoredsee MDN
If you don't return something, the actions within the handler function are executed before the page unloads.
You can't use dialogs (in some browsers) when a user is trying to leave the page. Otherwise you could just put a constant stream of alerts.