Skip to content

Instantly share code, notes, and snippets.

@ramons03
Last active January 11, 2017 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramons03/954600d41030ad0672388ebdb57e5898 to your computer and use it in GitHub Desktop.
Save ramons03/954600d41030ad0672388ebdb57e5898 to your computer and use it in GitHub Desktop.
Flashing HTML Title Script
(function () {
var original = document.title;
var timeout;
var defaultTimes = 5;
window.flashTitle = function (newMsg, howManyTimes) {
function step() {
document.title = (document.title == original) ? newMsg : original;
if (--howManyTimes > 0) {
timeout = setTimeout(step, 1000);
};
};
howManyTimes = parseInt(howManyTimes);
if (isNaN(howManyTimes)) {
howManyTimes = defaultTimes;
};
cancelFlashTitle(timeout);
step();
};
window.cancelFlashTitle = function () {
clearTimeout(timeout);
document.title = original;
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment