Подтвердите перед выходом на страницу JavaScript

//says: do you want to leave this site changes may not be saved
window.onbeforeunload = function(e) {
  return "Do you want to exit this page?";
};
Dangerous Deer