Created
August 4, 2020 17:41
-
-
Save Quellens/7871c36e84d186baf480cc733be98939 to your computer and use it in GitHub Desktop.
This script detects wheter the User is going away from your website or not. If you set the Title in HTML, this title will be the first that the user sees. Then => document.title = 'Hey! Come back!' Then => document.title = 'Nice to See you again! π';
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
//If you set the Title in HTML, this title will be the first that the user sees. Then => document.title = 'Hey! Come back!' Then => document.title = 'Nice to See you again! π'; | |
addEventListener('blur', () => { | |
document.title = 'Hey! Come back!'; | |
}); | |
addEventListener('focus', () => { | |
document.title = 'Nice to See you again! π'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment