JSFiddle - React, Tailwind, and code Playground
HTML
<a href="http://google.com">link</a>
JavaScript
var show_close_alert = true;
$("a").bind("mouseup", function() {
show_close_alert = false;
});
$("form").bind("submit", function() {
show_close_alert = false;
});
$(window).bind("beforeunload", function() {
if (show_close_alert) {
return "Killing me won't bring her back...";
}
});