0

I use Visibility API script from here: Detect if browser tab is active or user has switched away

Everything working ok, but when I swich another app window, the first window browser should return "not visible" as document title but it doesn't work in that way. For example, I use Chrome browser and then I click to Mozilla Firefox browser - first widnow (Chrome) is "not visible" now because Firefox window is visible now. But chrome window always return "visible" status.

I tried use this:

return function(c)
    {
        if (c)
        {
            document.addEventListener(eventKey, c);
            document.addEventListener("blur", c); // THIS
            document.addEventListener("focus", c); // AND THIS
        }

        return !document[stateKey];
    }

but it doesn't work too. Anyone can help me? Thanks.

Pavlo P
  • 37
  • 1
  • 6
  • Does this answer your question? [visibilitychange event is not triggered when switching program/window with ALT+TAB or clicking in taskbar](https://stackoverflow.com/questions/28993157/visibilitychange-event-is-not-triggered-when-switching-program-window-with-altt) – Chayim Friedman Apr 06 '20 at 07:35
  • @ChayimFriedman tried use these examples in VISIBILITY API function but nothing work fine :/ – Pavlo P Apr 06 '20 at 07:42
  • This resource states that the specs don't define _when something is visible_. – Chayim Friedman Apr 06 '20 at 07:44
  • Thus you can use the old way of focus/blur; the visibility api won't solve your problem – Chayim Friedman Apr 06 '20 at 07:44

0 Answers0