I have this code that makes me send a confirmation message to the user wanting to leave my website, everything works fine.
window.addEventListener('beforeunload', function(event) {
var confirmationMessage = '¿Seguro que quieres salir?';
event.returnValue = confirmationMessage;
return confirmationMessage;
});
The problem is that I want that code to have a button that says "If you ask" and another that says "Do not Ask" and that by pressing do not ask, the alert message will not come out when leaving the page
I need the code to work with these two buttons but I do not know how to do it
<input type="button" value="Preguntar" onclick="bPreguntar = true;" >
<input type="button" value="No preguntar" onclick="bPreguntar = false;" >