简体   繁体   English

当标签处于活动/非活动状态时,如何让标签更改其标题?

[英]How can I make an tab change it's title when it's active/inactive?

I noticed Mellow Mushroom's website tabs change depending on if it is active or not.我注意到 Mellow Mushroom 的网站标签会根据它是否处于活动状态而变化。 I'd like to be able to reproduce this on my personal site.我希望能够在我的个人网站上重现此内容。

Here's a video in case you don't know what I mean ---> https://imgur.com/i4MLMKz这是一个视频,以防您不明白我的意思---> https://imgur.com/i4MLMKz

Will I need to do this in JavaScript?我需要在 JavaScript 中执行此操作吗?

It's really just two steps.其实只要两步。 Detect if the browser window is active.检测浏览器窗口是否处于活动状态。 That question was asked and answered here: Is there a way to detect if a browser window is not currently active?在这里提出并回答了这个问题: 有没有办法检测浏览器窗口当前是否处于活动状态? . . Then you can just set the document.title property.然后你可以只设置 document.title 属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM