May 12, 2020 02:54 pm GMT
Original Link: https://www.knutmelvaer.no/blog/2020/05/how-i-put-the-scroll-percentage-in-the-title-bar/
How I Put the Scroll Percentage in the Browser Title Bar
Some nice trickery from Knut Melvr.
Ultimately the trick boils down to figuring out how far you’ve scrolled on the page and changing the title to show it, like:
document.title = `${percent}% ${post.title}`
Knut’s trick assumes React and installing an additional library. I’m sure that library does all kinds of smart stuff, but if you’re looking to do this “vanilla” style, I’d probably rock something like this…
const percentLabel = document.querySelector("#percent");const originalTitle = document.title;window.addEventListener("scroll", () ={
… Read article “How I Put the Scroll Percentage in the Browser Title Bar”
The post How I Put the Scroll Percentage in the Browser Title Bar appeared first on CSS-Tricks.
Original Link: https://www.knutmelvaer.no/blog/2020/05/how-i-put-the-scroll-percentage-in-the-title-bar/
Share this article:
Tweet
View Full Article