Last active
June 19, 2018 11:14
-
-
Save Stoffo/ead4ec8e51b23882c8d9 to your computer and use it in GitHub Desktop.
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
var defaultTitle = document.title; | |
// subscribe to visibility change events | |
document.addEventListener('visibilitychange', function () { | |
// fires when user switches tabs, apps, goes to homescreen, etc. | |
if (document.visibilityState === 'hidden') { | |
document.title = 'Baby, Come Back!' | |
} | |
// fires when app transitions from prerender, user returns to the app / tab. | |
if (document.visibilityState === 'visible') { | |
document.title = defaultTitle; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taken from igvita.com.