Home > database >  Alt tab page title "animation"
Alt tab page title "animation"

Time:04-29

I want to "animate" the page title in the browser tab to alternate between two states every second like this example:

  1. Page Title
  2. ⭐ Page title

How can I do this?

Thanks!

CodePudding user response:

You could do something like:

const star = "⭐ ";

setInterval(() => {
  if (!document.title.startsWith(star))
    document.title = star   document.title;
  else 
    document.title = document.title.replace(star, '');
}, 1000)

  • Related