i’m interested in knowing when the page is active and when it’s not (another browser window, or tab, or different app, is in front). i found this code:
if (/*@cc_on!@*/false) { // check for Internet Explorer
document.onfocusin = onFocus;
document.onfocusout = onBlur;
} else {
window.onfocus = onFocus;
window.onblur = onBlur;
}
in both my browsers this works only partly and in different ways.
in an old mac safari blur happens when the app is changed away from the browser (and focus when changed back), and when a new browser window is made active (and focus when original window made active again), but doesn’t work with tabs; don’t get blur when a new tab is created and accessed or an already existing one is accessed (nor focus when switching tabs back to original tab).
in a mac firefox it works with tabs and different windows, but on app switch no blur event but there is a focus event when making browser app (with original window in front) active again.
presumably there’s going to be all manor of anomilies with other browsers. any one know of some already existing code which attempts to cope with these differences and get round some of them?
or, a couple of more specific questions: how to get safari to report tab changes, and how to get firefox to report the app losing focus?
thanks.