2

I have one problem with this API. Everything works good but when I open something over or switch to some application which will be over the browser(i didnt minimize browser, just opened something over it), api doesnt work and hidden status = false. Some on know how to fix it?

1 Answers1

2

Considering https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API and Mozilla's demo this is intended behaviour. The "focus" that is mentioned in the docs only applies to the tab, not to the whole browser window (if I understand it correctly).

For the sake of completeness, this is from http://www.w3.org/TR/page-visibility/:

On getting, the visibilityState attribute MUST return the DOMString visible if the Document contained by the top level browsing context is at least partially visible at on at least one screen. This is the same condition under which the hidden attribute is set to false.

To accommodate accessibility tools that are typically full screen but still show a view of the page, when applicable, on getting, the visibilityState attribute MAY return the DOMString visible when the User Agent is not minimized but is fully obscured by other applications.

For checking whether the whole window is in focus you could use document.hasFocus() as described here: https://stackoverflow.com/a/3479960/2445864

Community
  • 1
  • 1
Hubert Grzeskowiak
  • 15,137
  • 5
  • 57
  • 74