onunload event triggerWhen we exit a page or close the browser tab we can trigger an event by using onunload . However when we close the browser then it can't be displayed. To check this code open the demo page in one new tab and then try to close the tab or visit to a different URL to exit the page. The source code of the demo page is here.
Here is the demo of onunload event
The source code of the demo page is here.
This will work on Firefox and Internet Explorer borwer