Show DevBest Flashing page title (Like Facebook)

NSA

sudo apt-get thefuckout.tar.gz
Dec 9, 2011
715
86
Hello!

I was browsing the tinterwebz when I came across a page which showed how to create the "New message from [username]" title like on Facebook.

Here is the script:
<script type="text/javascript">
function displayName() {
(function () {

var original = document.title;
var timeout;

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 = 5;
};

clearTimeout(timeout);

step();
};

window.cancelFlashTitle = function () {
clearTimeout(timeout);
document.title = original;
};

}());
Usage:

flashTitle("New Message from Matt Lunn");
or

flashTitle("New Message from John Smith", 10); // toggles it 10 times.
}
displayName();
</script>

Enjoy!

Source:
 

Users who are viewing this thread

Top