Efectivamente
bueno para los que quieren la solución inestable que encontré, lo rescatable de dicha solución sería que window.onbeforeunload es cross-browser
Código Javascript
:
Ver originalvar dont_confirm_leave = 0; //set dont_confirm_leave to 1 when you want the user to be able to leave withou confirmation
var leave_message = 'You sure you want to leave?'
window.onbeforeunload= function (e) {
if(dont_confirm_leave!==1) {
if(!e) e = window.event;
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = leave_message;
//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
// acá va la llamada ajax o código js
//return works for Chrome and Safari
return leave_message;
}
};
Saludos!