Created
January 10, 2019 19:38
-
-
Save luizcarraro/ce8555d519af341ec1e7e668f03bf991 to your computer and use it in GitHub Desktop.
Makes browser tab blink with text
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
var blinkTab = function(message) { | |
var oldTitle = document.title, /* save original title */ | |
timeoutId, | |
blink = function() { document.title = document.title == message ? ' ' : message; }, /* function to BLINK browser tab */ | |
clear = function() { /* function to set title back to original */ | |
clearInterval(timeoutId); | |
document.title = oldTitle; | |
window.onmousemove = null; | |
timeoutId = null; | |
}; | |
if (!timeoutId) { | |
timeoutId = setInterval(blink, 1000); | |
window.onmousemove = clear; /* stop changing title on moving the mouse */ | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment