在浏览器中切换到其他打开的选项卡时,更改标题标签的内容 [英] Change content of title tag, when switching to other open tab in the browser

查看:210
本文介绍了在浏览器中切换到其他打开的选项卡时,更改标题标签的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在两个不同的网站上看到了这一消息,有人知道它是如何完成的吗? 如果打开了多个选项卡,而保留了当前的选项卡,则选项卡中的标题将更改.很好玩!

I just recently saw this on two different websites, does anyone know how it is done? If you have multiple tabs open, and you leave the current one, the title in the tab is changed. Very nice trick!

http://blog.invisionapp.com/

http://zerosixthree.se/create-a响应头视频具有优美的降级效果/

推荐答案

这是通过在windowonfocusonblur事件上注册处理程序来实现的.

This works by registering Handlers on the onfocus and onblur events of window.

jQuery风格:

$(window).on('blur', function() { ... });

没有jQuery:

window.onblur = function() { ... }

如果不清楚,可以通过document.title

If that was not clear: the pages title can be read/written via document.title

这篇关于在浏览器中切换到其他打开的选项卡时,更改标题标签的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆