views:

326

answers:

1

Hi,

i'm writing a extension, which needs to call some JS from the current tab/document when user closes this tab (some saving etc). document.onbeforeunload doesn't do it for me, because it's also called when the page is reloaded. I'm looking for something like tryToClose but for tabs.

+3  A: 

You need to listen to "TabClose" event within the extension as illustrated at Notification when a tab is added or removed

I'm able to catch the event. Any pointers on how to prevent the closing of the tab? I attempted event.stopPropagation() on the handler code. It does not stop the closing of the tab!

Balaji Sowmyanarayanan
Thank you, now i can catch the event, too. Likely to you i also have to stop tab from closing.