Detect Browser or Tab Close Event



I want to log user’s activity to a database table during login, logout, session expired and when browser is closed. How do I detect or intercept when a user closes the browser, tab, exit menu and Alt-F4?

A small sample would be highly appreciated.


  • You must to post comments

Unfortunately for a browser there is no difference between closing the browser, closing the tab, refreshing or navigating.

Wisej has a keepalive system that will detect a dead session and kill it. You can handle Application.ApplicationExit to know that the session has been disposed. You cannot really do much in ApplicationExit since the session is already gone. The wisej objects (windows, controls, etc) are available , but if you change them the changes are lost.

You can also handle Application.SessionTimeout which occurs right before removing the session. In SessionTimeout you can still handle objects in that session.


  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.