Answer the question
In order to leave comments, you need to log in
Window close confirmation in Chrome?
Everyone knows the nasty alert window when you close the "Are you sure that ...?"
Let's not talk about the ethics of this action (this feature also has normal applications: for example, a warning for unsaved data in the text input editor), I wonder how some sites still manage to bypass the blocking of this window by Chrome? 'Cause it doesn't work
window.onbeforeunload = function(e) {
return 'Dialog text here.';
}
window.addEventListener("beforeunload", function (event) {
alert("Hello! I am an alert box!!")
event.preventDefault()
})
Answer the question
In order to leave comments, you need to log in
Who told you they don't work?
test (press ctrl+U in browser to view source)
Documentation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question