How can I tell if the browser close button is clicked?
From the JavaScript Event Reference , the closest match is the OnUnload event. However, this also catches navigation from the page (and therefore, you do not want the functions to run if the user really clicks on the link.)
There is no guarantee that the server will receive a message about closing the browser window. For example, an older method that involved creating a small popup would be blocked by most modern browsers. Using AJAX may work, but the browser window may close before trying to connect.
:
$(window).unload( function () { alert("Bye now!"); } );
?
jQuery.
, Demoli, ( ).
edit: .
, , ,
, ,
onbeforeunload, onunload. IE 7 (, , ) 100% , unload, beforeunload.
onbeforeunload
onunload
unload
beforeunload
, window.onbeforeunload=function(){}
window.onbeforeunload=function(){}
, prototype.js: Event.observe(window, 'beforeunload', function(){});
Event.observe(window, 'beforeunload', function(){});
, , , . IE. IE.
<body onunload="if(self.screenTop>9000){unloadFunction();}">
, , unloadFunction , . , . !;)
, (?) - .
window.closed, . , .
, , "" - .
, , .
ajax-, ( ) . (, ), .
Northsouthwhat, , onbeforeunload , , , .
Source: https://habr.com/ru/post/1699092/More articles:Создание динамических полей с использованием ActiveRecord:: Serialization.to_xml - rubyIs there an easy way to clone table structure in Oracle? - javaExamples of one line code in different languages for MD5 - md5In .Net, what's the best choice for entering a code by pressing a key on a keyboard, keyboard, or keyboard? - c #How to use varnish / squid with IIS / ASP.NET website? - asp.net-mvcКак имитировать медленный принтер в Windows XP? - windows-xpMake defining external SVN versions flawless? - version-controlMySQL INSERT simple error - mysqlDetect if Adobe Reader is installed using VB code - scriptingПолучить путь метабазы для записи IIS (установка остановлена, потому что указанный путь не является допустимым веб-приложением) - asp.netAll Articles