JSFiddle - React, Tailwind, and code Playground
JavaScript
// https://developer.mozilla.org/en/DOM/window.onbeforeunload
var flag = true;
window.onbeforeunload = function()
{
alert("flag: "+flag);
if ( /Firefox[\/\s](\d+)/.test(navigator.userAgent) && new Number(RegExp.$1) >= 4 )
{
var div_unload = document.createElement("div");
div_unload.innerHTML = "<h1 style='text-align:center'>DON'T LEAVE BEFORE SAVING YOUR WORK!!!</h1><p>You may loose the changes to the following documents:<ul><li>Document 1</li><li>Important document 2</li><li>REALLY important document 3</li></ul></p>";
div_unload.innerHTML += "<p><small>Unfortunately you are using a recent version of Firefox which disables customizing the text of the unbeforeunlaod dialog, so we suggest you using another browser with this web app.<br />[Chrome Link] [IE9 Link] [Safari Link] [Opera Link]</small></p>";
document.body.appendChild(div_unload, document.body.firstChild);
}
if (flag) return "You have not saved Document 1, Important document 2 and REALLY important document 3, do you want to leave?";
flag = true;
}