Skip to content

Instantly share code, notes, and snippets.

@underdown
Created June 26, 2013 16:35
Show Gist options
  • Select an option

  • Save underdown/5869012 to your computer and use it in GitHub Desktop.

Select an option

Save underdown/5869012 to your computer and use it in GitHub Desktop.
cribbed from infinum.co
init = function () {
var e, t, n;
typeof document.hidden != "undefined" ? (e = "hidden", n = "visibilitychange", t = "visibilityState") : typeof document.mozHidden != "undefined" ? (e = "mozHidden", n = "mozvisibilitychange", t = "mozVisibilityState") : typeof document.msHidden != "undefined" ? (e = "msHidden", n = "msvisibilitychange", t = "msVisibilityState") : typeof document.webkitHidden != "undefined" && (e = "webkitHidden", n = "webkitvisibilitychange", t = "webkitVisibilityState"), t && $(document).on(n, function (e) {
var n = "Come back! We miss you!";
document[t] === "visible" && typeof window.originalDocumentTitle != "undefined" && (document.title = window.originalDocumentTitle), document[t] === "hidden" && document.title !== n && (window.originalDocumentTitle = document.title, document.title = n)
}),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment