Skip to content

Instantly share code, notes, and snippets.

@desprit
Created July 1, 2022 11:45
Show Gist options
  • Save desprit/c9704d4f758e911f0ac58ccd665b73fc to your computer and use it in GitHub Desktop.
Save desprit/c9704d4f758e911f0ac58ccd665b73fc to your computer and use it in GitHub Desktop.
Never ever do this on your website
(function () {
var titleValue = document.title;
var hidden = "hidden";
function onchange() {
document.title = document.hidden ? "Pssst! We’re Still Here…" : titleValue;
}
if (hidden in document) {
document.addEventListener("visibilitychange", onchange, false);
}
else if ((hidden = "mozHidden") in document) {
document.addEventListener("mozvisibilitychange", onchange, false);
}
else if ((hidden = "webkitHidden") in document) {
document.addEventListener("webkitvisibilitychange", onchange, false);
}
else if ((hidden = "msHidden") in document) {
document.addEventListener("msvisibilitychange", onchange, false);
}
// IE 9 and lower:
else if ("onfocusin" in document) {
document.onfocusin = document.onfocusout = onchange;
}
else
window.onpageshow = window.onpagehide
= window.onfocus = window.onblur = onchange;
})();
@desprit
Copy link
Author

desprit commented Jul 1, 2022

Copied from Sarova hotel engine.
https://bookings.sarova.com/rates-room

When you go away from the Sarova tab, the <title> changes to Pssst! We’re Still Here…. And instead of having a clear title, you get this weird shit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment