How do I animate site title of site in browser tab like this?
Asked
Active
Viewed 7,672 times
0
-
Check [this answer](https://stackoverflow.com/questions/23731357/how-do-i-make-text-inside-the-title-tag-animate-using-javascript). – Sam Oct 24 '17 at 23:29
3 Answers
1
You can add a scroll animation to the title of your browser tab using this Javascript code:
msg = "Title";
msg = " ...Just a scrolling title example" + msg;position = 0;
function scrolltitle() {
document.title = msg.substring(position, msg.length) + msg.substring(0, position); position++;
if (position > msg.length) position = 0
window.setTimeout("scrolltitle()",170);
}
scrolltitle();
0
This is pure js...
function recursiveAnimateTitle(string) {
let firstLetter = string[0];
let title = document.querySelector('title');
title.innerHTML += firstLetter;
if (string.length > 1) {
setTimeout(function() {
recursiveAnimateTitle(string.substring(1));
}, 100);
}
}
function animateTitle(string) {
document.querySelector('title').innerHTML = "";
recursiveAnimateTitle(string);
}
animateTitle('Example Title');
<head>
<title>Some Default Title</title>
</head>
<body></body>
If you want to vary the time for each letter, use math.random with a range.
With a distribution if you want to get really weird with it.

Amos47
- 695
- 6
- 15