How to determine if a popup page is open or not?

I am working on a Chrome extension and I am looking for how to find out (from the background page) if the pop-up page is open or not. I looked through the post, but I'm not sure if this will help me with this, or if there is an easier way.

Thank!

+5
source share
1 answer

You can use the following chrome API call from your background page if the popup is open:

var views = chrome.extension.getViews({ type: "popup" });

//views => [] //popup is closed
//views => [DOMWindow] //popup is open

If it returns an empty array, your popup will not be open, if it returns an array with your DOMWindow object, then the popup is open.

, DOMWindow .

+12

All Articles