The event is described here https://developer.mozilla.org/en-US/docs/Web/Events Can not find an analogue for chrome. Help me please.

    1 answer 1

    Found in the open spaces.

    Analogue with jQuery . Checked in Chrome , Firefox .

     function Unloader(){ var o = this; this.unload = function(evt) { var message = "Вы уверены, что хотите покинуть страницу. Ведь данные могут потеряться?"; if (typeof evt == "undefined") { evt = window.event; } if (evt) { evt.returnValue = message; } return message; } this.resetUnload = function() { $(window).off('beforeunload', o.unload); setTimeout(function(){ $(window).on('beforeunload', o.unload); }, 2000); } this.init = function() { $(window).on('beforeunload', o.unload); $('a').on('click', function(){o.resetUnload}); $(document).on('submit', 'form', function(){o.resetUnload}); $(document).on('keydown', function(event){ if((event.ctrlKey && event.keyCode == 116) || event.keyCode == 116){ o.resetUnload; } }); } this.init(); } $(function(){ if(typeof window.obUnloader != 'object') { window.obUnloader = new Unloader(); } }) 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

    In Firefox message cannot be changed. It will be standard о не сохраненных данных .

    If you run the script, the current window when updating / closing will ask the user about his desire to continue the action.