0

I'm writing a Chrome Extension that opens an external (detached) window that is meant to be open for the rest of the session.

I'd like to get an event when the main window (with many tabs) is closing so that I close my tab before the main window. Otherwise, the tab will remain open and the user needs to close it manually. Thus, Chrome will remember it as the next time Chrome will open it instead of the other tabs that were in the main window. Obviously, this is a bad user experience.

The background script doesn't get any event when the main window closes.

Any idea how I could get this?

7
  • Sorry for initially considering your question trivial. What you want is preserving the "main" window as the last window closed for session restoration purposes. windows.onRemoved will be too late.
    – Xan
    Jan 27, 2015 at 12:32
  • 1
    Have you considered opening your window as an incognito window?
    – Xan
    Jan 27, 2015 at 12:33
  • That works. Thanks. I'm afraid that I'd need to store some session information and that could not work with the incognito session. Is there a formal way to do this without this workaround?
    – Mario
    Jan 27, 2015 at 12:41
  • I can think of a very, very UGLY one I shall not even mention.. Does that window contain a page from your extension or an external website? Note that with spanning Incognito behavior you can fake persistence.
    – Xan
    Jan 27, 2015 at 12:43
  • It's loading a server page. If there's not easy way, I'll go with this workaround for now. Although I don't find it perfect that the extension tab is left orphan. Thanks.
    – Mario
    Jan 27, 2015 at 12:48

0

Your Answer

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

Browse other questions tagged or ask your own question.