Guest User

Untitled

a guest
May 21st, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. function setConfirmUnload(on) {
  2.  
  3. window.onbeforeunload = (on) ? unloadMessage : null;
  4.  
  5. }
  6.  
  7. function unloadMessage() {
  8.  
  9. return 'You have entered new data on this page. If you navigate away from this page without first saving your data, the changes will be lost.';
  10.  
  11. }
  12.  
  13.  
  14. $(document).ready(function() {
  15.  
  16. $(':input',document.myForm).bind("change", function() { setConfirmUnload(true); }); // Prevent accidental navigation away
  17. });
  18.  
  19. 300 jQuery(window).unload(function(e) {
  20. 301 var chg = jQuery(".crayon-changed");
  21. 302 if (chg.length && uniConfirm(configCrayons.txt.sauvegarder)) {
  22. 303 chg.next().find('form').submit();
  23. 304 }
  24. 305 });
  25.  
  26. jQuery(window).bind('beforeunload', function(event) {
  27. event.stopPropagation();
  28. event.returnValue = "Attention !nVous n'avez pas sauver vos paramètres.nSi vous appuyer sur OK, vous perdrez les informations en cours d'utilisation...nnLa fenêtre est sur le point de se fermer";
  29. return event.returnValue;
  30. });
Add Comment
Please, Sign In to add comment