3

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.

1 Answer 1

4

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!

2
  • Thank you, now i can catch the event, too. Likely to you i also have to stop tab from closing.
    – user164039
    Sep 15, 2009 at 8:21
  • TabClose is only fired for a subsequent tabs. Do you know what event is fired when the last tab is closed? May 23, 2011 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.