JSFiddle - React, Tailwind, and code Playground
by shomz
HTML
<div id="x"></div>
JavaScript
var x = false;
document.getElementById('x').innerHTML = x;
window.onbeforeunload = function(e) {
x = true;
document.getElementById('x').innerHTML = x;
return "Click STAY ON PAGE then SAVE to save any data you've entered.\n If you've already SAVED select LEAVE PAGE to continue.";
}