Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Change page title when browser tab is unfocused
* Usage
* The following code will modify the title of the browser tab on the "blur" event and change it back to the original on the "focus" event.
// store the original tab title
var origTitle = document.title;
// function to change title when focusing on tab
function oldTitle() {
document.title = origTitle;
// function to change title when un-focusing on tab
function newTitle() {
document.title = 'HELLO WORLD';
// bind functions to blur and focus events
window.onblur = newTitle;
window.onfocus = oldTitle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment