Page Visibility API visibility test using jQuery
var isVisible = false; | |
function onVisible() { | |
isVisible = true; | |
jQuery.getScript("http://www.google-analytics.com/ga.js"); | |
} | |
if ( document.webkitVisibilityState === undefined || document.webkitVisibilityState === "visible" ) { | |
onVisible(); | |
} else { | |
jQuery.bind( "webkitvisibilitychange", function() { | |
if ( !isVisible && document.webkitVisibilityState === "visible" ) { | |
onVisible(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment