Answer the question
In order to leave comments, you need to log in
How to protect a page from being accidentally closed in Google Chrome?
Tried like this:
window.addEventListener('beforeunload', function() {
event.preventDefault();
confirm('Действительно закрыть приложение? Все данные будут потеряны!');
});
Answer the question
In order to leave comments, you need to log in
Thanks everyone, got it. It should turn out like this:
window.onbeforeunload = function() {
return false;
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question