Javascript - detect the closing event

Ask a question

[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

How To Disable JavaScript on Google Chrome
SRWare Iron - Disable Javascript