Created
July 25, 2014 13:12
-
-
Save seanwalsh/7d4201eed50d9da53b62 to your computer and use it in GitHub Desktop.
A little bit of Javascript to change the title of a page after loosing focus. For example, switching to another window or tab.
This file contains 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
// Change Title Tag on Blur | |
var titleCurrent = document.title; | |
var titleList = [ | |
"Hey, over here.", | |
"Don't you forget about me", | |
"Please come back" | |
]; | |
var titleIndex = ""; | |
function titleRandom(){ | |
var index = Math.floor(Math.random() * titleList.length); | |
titleIndex = titleList[index]; | |
document.title = titleIndex; | |
} | |
window.onblur = function () { titleRandom(); }; | |
window.onfocus = function () { document.title = titleCurrent; }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment