JSFiddle - React, Tailwind, and code Playground

by Roger Sanchez

HTML

<body onunload="salir();">
    
</body>

JavaScript

window.onbeforeunload = askWhetherToClose;
function askWhetherToClose(event) {
    var msg;

    msg = "Juan, seguro que quieres cerrar la pagina? xD";
    event = event || window.event;
    event.returnValue = msg;
    return msg;
}

function salir(){
  alert('osea me dejas :C');
}