XML. The focused and unfocused handlers make sure that the callback isn't called multiple times if multiple APIs catch the same visibility change.
You can use the jQuery :visible selector to check whether an element is visible in the layout or not. visibility.js is a library that abstracts this across all browsers. jQuery makes it easy to determine if an element is visible or hidden with the is() function. due to Alt+Tab (probabilistic = not 100% accurate), User attention potentially not focused on the HTML page (probabilistic = not 100% accurate), IE8 - always indicate that tab/window is currently active (, The page includes iframes that you have no control over, You want to track visibility state change regardless of the change being triggered by a TAB change (ctrl+tab) or a window change (alt+tab). Does hillbilly slang fall under a type of English language and if not, what is it called? If you can find more info about where this doesn't work, please let me know in the comments below. - document.activeElement. Does visibility.js actually add the functionality to the old browsers? you could use onkeypress or other similar events to reset the timer and solve the non-mouse issue. If element is regular visible (display:block and visibillity:visible), but some parent container is hidden, then we can use clientWidth and clientHeight for check that. In practice this means that the page is the foreground tab of a non-minimized window.
Efficient, and unlike the other solutions gives correct feedback when you switch to another browser tab or window, and even a different application. :) Just to make it clear "Visible in DOM" or "Visible on screen" or "Visible in viewport" or "Visible within the container with scrollbars" — all of those mean different things and implementations. Would it be possible to mount a working minigun onto the saddle of a tyrannosaurid dinosaur?
What is the maximum length of a URL in different browsers? your coworkers to find and share information. Reading your truth from the DOM is Bad. However, your specific use-case is slightly different from the standard one, so I'll refrain from flagging: (EDIT: OP SAYS HE'S SCRAPING PAGES, NOT CREATING THEM, SO BELOW ISN'T APPLICABLE) How can some USB 2.0 audio interfaces support phantom power through USB alone? Answer: Use the jQuery :visible Selector. The visibility property sets or returns whether an element should be visible. A better option? But it has problems with simple elements that do not have a css layout, see more here. In Firefox, if you click inside firebug console (on the same page), the, This no longer works for current versions of modern browsers, see the approved answer (Page Visibility API), This solution doesn't work on iPad please use "pageshow" event, Both BLUR and FOCUS fires off when the page loads.