Is there any way to cancel unload () or OnBeforeUnload ()? Something like this:
window.onbeforeunload = function(){
//ação aqui
break; //cancela o fechamento da pagina sem exibir nenhum alert
}
I need to open a div (popup) when the user clicks close or back, the idea was to place
document.getElementById('minhaDiv').style.display = 'block';
before the break, but this does not work because the break does not work and the page is closed. I hope you understand this salad a little!