I'm developing a web application and need to perform a function when the client clicks the browser's X or simply closes it.
To be more specific, I need to execute an ajax call on this closing.
Is there any way to do this?
I'm developing a web application and need to perform a function when the client clicks the browser's X or simply closes it.
To be more specific, I need to execute an ajax call on this closing.
Is there any way to do this?
It is not possible to distinguish between the user clicking on the CLOSE of the browser, when it closes the tab or when it leaves your site through a link, but fortunately it is possible to detect when one of these events happens, and it is through the events onunload and onbeforeunload.
I recommend using jQuery because you already handle possible differences between browsers: