1

I'm building a chrome extension who should get when browser is focused or not. I'm using a background script defined in my mainfest.json. Something like this:

chrome.windows.onFocusChanged.addListener(function(window){
    if (window == chrome.windows.WINDOW_ID_NONE) {
        //Do something
    }
});

But the event isn't always fired on focus change. I've followed this question and its relative answer to the Google Issue Forum here.

From google docs

Fired when the currently focused window changes. Will be chrome.windows.WINDOW_ID_NONE if all chrome windows have lost focus.

From issue answers Jan 20, 2015

[...]chrome does not fire onfocusChange event in every possible situation, only between chrome windows or between another app if new tab is currently active tab. [...]it looks like dev's not interested currently in chrome.windows API

My question. Is it actually possible catch anytime the browser has focus in a chrome extension?

Thanks in advance.

Community
  • 1
  • 1
Nicolò
  • 186
  • 1
  • 16
  • Have you check this? http://stackoverflow.com/questions/36009207/chrome-windows-onfocuschanged-addlistener-not-firing-on-tab-switching – Android Enthusiast May 16 '16 at 08:22
  • Just checked thank you. So, does anyone know how to get when window is focused from a chrome extension? I'm asking if are there any ways to do that at this moment.. – Nicolò May 16 '16 at 15:21
  • Can you add a reproducible example of this event not firing (including OS)? – Xan May 24 '16 at 08:56

0 Answers0