ifvisible.js
ifvisible.js copied to clipboard
detecting external windows active
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
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!
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.