Last active
January 11, 2017 12:57
-
-
Save ramons03/954600d41030ad0672388ebdb57e5898 to your computer and use it in GitHub Desktop.
Flashing HTML Title Script
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
(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