4 lines of JavaScript to boost your site’s personality. ⚡️ You’ve probably seen this effect on to...4 lines of JavaScript to boost your site’s personality. ⚡️ You’ve probably seen this effect on to...
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
4 lines of JavaScript to boost your site’s personality. ⚡️
You’ve probably seen this effect on top-tier SaaS sites. When a user clicks away, the tab title changes to "Come back!" or "Don't forget this..."
Here is the exact code to do it yourself. No heavy libraries, just native JS.
Copy/Paste this into your </body> code: const documentTitleStore = document.title; const documentTitleOnBlur = "Come back! We miss you"; // Define your custom title here
// Set original title if user is on the site window.addEventListener("focus", () => { document.title = documentTitleStore; });
// If user leaves tab, set the alternative title window.addEventListener("blur", () => { document.title = documentTitleOnBlur; });
Helpful or Annoying? Let me know in the comments! 👇
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started