Javascript - detect the closing event

October 2016

[Javascript] detect the closing event


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


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


Solved by foxmaster

Related :

This document entitled « Javascript - detect the closing event  » from CCM ( 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.