Created
February 2, 2015 21:55
-
-
Save iainmcampbell/4317113e64996352db1e to your computer and use it in GitHub Desktop.
Page Visibility API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hidden | |
, visibilityChange | |
// browser prefixes | |
if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support | |
hidden = "hidden" | |
visibilityChange = "visibilitychange" | |
} else if (typeof document.mozHidden !== "undefined") { | |
hidden = "mozHidden" | |
visibilityChange = "mozvisibilitychange" | |
} else if (typeof document.msHidden !== "undefined") { | |
hidden = "msHidden" | |
visibilityChange = "msvisibilitychange" | |
} else if (typeof document.webkitHidden !== "undefined") { | |
hidden = "webkitHidden" | |
visibilityChange = "webkitvisibilitychange" | |
} | |
function handleVisibilityChange() { | |
if (document[hidden]) { | |
} else { | |
} | |
} | |
if (typeof document.addEventListener === "undefined" || typeof document[hidden] === "undefined"){ | |
document.addEventListener(visibilityChange, handleVisibilityChange, false) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mdn