Skip to content

Instantly share code, notes, and snippets.

@Quellens
Created August 4, 2020 17:41
Show Gist options
  • Save Quellens/7871c36e84d186baf480cc733be98939 to your computer and use it in GitHub Desktop.
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! πŸ˜„';
//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