Last active
November 19, 2015 17:48
-
-
Save Jhony0311/6cc9526869a034bae0ad to your computer and use it in GitHub Desktop.
Browser tab visibility control
This file contains hidden or 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 eventName = "visibilitychange"; | |
if (document.webkitHidden != undefined) { | |
eventName = "webkitvisibilitychange"; | |
} else if (document.mozHidden != undefined) { | |
eventName = "mozvisibilitychange"; | |
} else if (document.msHidden != undefined) { | |
eventName = "msvisibilitychange"; | |
} else if (document.hidden != undefined) { | |
} else { | |
} | |
function visibilityChanged() { | |
if (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden) { | |
/* tab invisible */ | |
} else { | |
/* tab visible */ | |
} | |
} | |
document.addEventListener(eventName, visibilityChanged, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment