Javascript - detect the closing event

December 2016


[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

Related :

This document entitled « Javascript - detect the closing event  » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.