2
Because this doesn’t work:
window.addEventListener('beforeunload', function(){
return 'wait a minute'
})
And this works:
window.onbeforeunload = function(){
return 'wait a minute'
}
They’re not the same?
2
Because this doesn’t work:
window.addEventListener('beforeunload', function(){
return 'wait a minute'
})
And this works:
window.onbeforeunload = function(){
return 'wait a minute'
}
They’re not the same?
2
The two do not work in the same way. The addEventListener
with the event beforeunload
requires event.returnValue
:
window.addEventListener('beforeunload', function(event){
var mensagem = "wait a minute";
event.returnValue = mensagem;
return mensagem;
});
More information in this MDN documentin English.
Browser other questions tagged javascript javascript-events
You are not signed in. Login or sign up in order to post.
Show!! That’s right, thanks!!
– Felipe Coelho