Last updated on February 9th, 2022 at 10:45 am
This script will help you to detect browser or tab close event and alert some messages. Even this script will be useful to call some Ajax functions which terminate connection to Database or something related.
Tested on latest version of Chrome and Internet Explorer 11.0 and Microsoft Edge. [Last validated on Sept 24th 2016]
Tested on latest version of Chrome, Firefox, Safari [Last validated on Feb 9th 2022]
You can try this code, it basically calls onbeforeunload property of the WindowEventHandlers
Note: In the demo you must type something in the input field or click somewhere in the page to activate the listener. Simply opening the demo page and closing it may not trigger a confirmation pop up