DEV Community

Cover image for Changing Tab Details
bob.ts
bob.ts

Posted on

4

Changing Tab Details

I stumbled onto an interesting pattern when checking out the Mellow Mushroom web page. It didn't hit me right away ... I left the page and had to come back and see if I really had observed the page title change when I switched tabs! Then, I had to figure out how it was done.

A quick search came up with the following question on Stack Overflow ... PERFECT!

So I am making a website and everything is nicely done but I don't know that many things with javascript.

I was searching for something that will help me with this and found some similar things but it doesn't work in my case.

This is the problem/idea:

  • User is on…

In the answers ...

window.onblur = function () {
  document.title = 'you left?';
}
window.onfocus = function () {
  document.title = 'WELCOME';
}
Enter fullscreen mode Exit fullscreen mode

Here's a working copy of the code above ...


AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay