ifvisible.js icon indicating copy to clipboard operation
ifvisible.js copied to clipboard

detecting external windows active

Open Kuhlig opened this issue 4 years ago • 2 comments

HI the demo is working well when i change Tab in a browser (chrome/firefox) but when i activate an other application, like notepad (or from firefox to chrome) there is no entry in the log? is there any way to detect that? thanks rob

Kuhlig avatar May 06 '20 08:05 Kuhlig

HI the demo is working well when i change Tab in a browser (chrome/firefox) but when i activate an other application, like notepad (or from firefox to chrome) there is no entry in the log? is there any way to detect that? thanks rob

If you check out https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API you'll see there's a note that mentions the normal browser "focus" functionality;

Note: While onblur and onfocus will tell you if the user switches windows, it doesn't necessarily mean it's hidden. Pages only become hidden when the user switches tabs or minimizes the browser window containing the tab.

If you really want to check if a window/page is in focus, you can use those built-in events. Just remember that users with multiple monitors or non-fullscreen windows can still technically "see" the page (potentially), and handle accordingly!

Drumstix42 avatar Sep 11 '20 03:09 Drumstix42

Author responded to another similar issue here: https://github.com/serkanyersen/ifvisible.js/issues/42#issuecomment-284213393

There's a legacy mode you can use in a newer (not "released" yet) that you can utilize.

Drumstix42 avatar Sep 11 '20 03:09 Drumstix42