fazlurr
3/15/2017 - 4:44 AM

Window Before Unload - http://stackoverflow.com/a/276739/5627904 - https://developer.mozilla.org/en/docs/Web/Events/beforeunload

// First Method
window.onbeforeunload = function() {
    return 'You have unsaved changes!';
};

// Second Method
window.addEventListener("beforeunload", function (e) {
  var confirmationMessage = "You have unsaved changes!";

  e.returnValue = confirmationMessage;     // Gecko, Trident, Chrome 34+
  return confirmationMessage;              // Gecko, WebKit, Chrome <34
});