Catching a tab close event in web browser?

asp-classic

Solution

Attach an "onbeforeunload" event. It can execute code just before the browser/tab closes.

Problem

Is there any way of knowing if the user closes a tab in a web browser? Specifically IE7, but also FireFox and others as well. I would like to be able to handle this situation from our asp code if the current tab containing our web site closes.

Original source