How to determine which popup is closed the extension in Chrome?

window.onclose does not help.

When you press the button, a window is created. And then, when it is closed, the link remains! References to functions to and called without problems from the background page! Events inside the popup (including setInterval) remain and work!

(FireFox in this respect easier - there is a popup immediately die, and all the links become "dead" and cause an error if using).

How to understand that popup is hidden? The problem is only in Chrome.
March 12th 20 at 08:04
1 answer
March 12th 20 at 08:06
If you need to keep a reference to the popup, the architecture of your extension really sad.
Use chrome.runtime.onMessage / chrome.runtime.sendMessage
either
https://developer.mozilla.org/en-US/docs/Web/API/B...
It's not the fact that the links on the popup are saved (and they still persist and work).

The problem is that after closing the popup it remains alive and it triggered various events, etc.

In the architecture of my application assumes that if the popup is closed, the information in it is not need to be updated to not load external services. But if open you can catch all the events. In particular, occur asynchronous requests to the Internet, depending on the situation - and live upload of data to display to the user.

Now while made a crutch - upgrade "heavy" information only once at the time of opening the popup (I know how to track). And about the close do not know. There is no way to determine whether or not the popup. From the point of view of the scripts he is active and available. - monserrat.Hilpert commented on March 12th 20 at 08:09
But if open you can catch all the events. In particular, occur asynchronous requests to the Internet, depending on the situation - and live upload of data to display to the user.

This is called upsetting.
Popup should be just a view for the data.
All business logic, network requests, etc. should be in the background. At least in my opinion.

To see the opening of a pop-up when PC, you can query all Windows of type popup, and then filter out the desired url, if more than one (actually, in practice this should not happen, but theoretically like there is no ban)
https://developer.chrome.com/extensions/windows#me...
+
https://developer.chrome.com/extensions/windows#ty... - domenica_Kuphal commented on March 12th 20 at 08:12
@monserrat.Hilpert, you can Still track the event of opening and closing Windows
https://developer.chrome.com/extensions/windows#ev...
but this method is not that solid. - domenica_Kuphal commented on March 12th 20 at 08:15

Find more questions by tags Extensions for browsersGoogle ChromeJavaScript