It is necessary that the block would pop up when trying to close the page. I tried many options from the stack, but not one did not work. Here are some examples:
window.onbeforeunload = confirmExit; function confirmExit() { var block = document.getElementById('leave'); block.classList.add('open') } $(window).bind('beforeunload', function() { alert('hello') }); This one earned:
window.onbeforeunload = function(){ return "Don't leave me!"; }; But you need to customize it, but not to display the text. Are there any other options?