Javascript - detect the closing event

October 2017


[Javascript] detect the closing event




Issue


How I can run a script before closing the window: after clicking on the X-USER closure. Thank you in advance

Solution


<script type="text/javascript"> 
function foo () 
{ 
alert ('foo'); 
} 
window.onbeforeunload = function () {foo ()}; 
</ Script>

Note


Solved by foxmaster
Published by aakai1056. Latest update on December 25, 2010 at 04:40 AM by aakai1056.
This document, titled "Javascript - detect the closing event ," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).