0

Hi,
I want to distinguish whether the tab closed by clicking X or by another action (clicking a link, or a button which close the current tab).

In Firefox - I followed the stack and saw that the function closing the tab (not by X) is called: onxblDOMWindowClose.
BUT in chrome - both cases's stack looks the same.

Is there any way I can know how the user close the current tab ?

I've googled this question in many versions, but didn't find any answer/work direction.

Any help will be appreciated.
Thanks.

3
Contributors
5
Replies
16
Views
1 Year
Discussion Span
Last Post by diafol
1

This is not a direct answer but how I would find out what event did it. As you know Chrome responds to "events" so I would have to monitor such events in some app or code. The good news is that CEL (link to follow) did release source code if you need to look how it was done. Noted link is http://blogs.fluidinfo.com/terry/category/browser-extensions/

But here's the thing. You can't be sure if the event was directly user created or say a system event like the OS was rebooted due to a pending update or other. I'm sure you can guess more scenarios that can close a tab where the user didn't click it.

0

Can you share the scenario in mind where this is important? Perhaps contributors could offer an alternative.

0

I needed to know if the window/tab closed by script or by browser action (clicking X button, for instence).
Chrome events wan't helpful in this case. So I re-implement window.close() - to announce me that the function has been called, and then close the window (also relevant to tab).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.