HOw to detect browser close button click

HOw to detect browser close button click

  
I want to call a event on click of browers close / tab close button.

How to detect that button close click and where to call the event.
Well.. I'm not sure you can detect browser click event. But you can workaround this by detecting the unload event that is triggered by closing the browser (see this link). Why would you want that anyway?

@Andre

I want to fire an event which will call API to clear the session on server so other user can use the resource
is there any way ?
Sunny Pathai wrote:

@Andre

I want to fire an event which will call API to clear the session on server so other user can use the resource
is there any way ?
 
 Hi Sunny,

follow the content in the link I've attached before. It shows how to detect window unload event. You can execute a javascript to click on a button and call a ScreenAction that clears the session.