jquery当浏览器切换到其它标签页时更改标题

所属分类: 网页特效-其它&杂项    2024-02-04 09:50:08

jquery当浏览器切换到其它标签页时更改标题 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery当浏览器切换到其它标签页时更改标题(共2个文件)

    • funtabify.js
    • index.html

使用方法

class funtabify {
	constructor(switchTitle) {
		jQuery(document).ready(function($) {

		(function() {
				var hidden = "hidden";
				var oldtitle = document.title;
				var currenttitle;

				// Standards based on browsers:
				if (hidden in document)
					document.addEventListener("visibilitychange", onchange);
				else if ((hidden = "mozHidden") in document) // For Mozilla Firefox
					document.addEventListener("mozvisibilitychange", onchange);
				else if ((hidden = "webkitHidden") in document) // For Chrome, Safari etc.
					document.addEventListener("webkitvisibilitychange", onchange);
				else if ((hidden = "msHidden") in document)
					document.addEventListener("msvisibilitychange", onchange);
				// IE 9 and lower:
				else if ("onfocusin" in document)
					document.onfocusin = document.onfocusout = onchange;
				// All others:
				else
					window.onpageshow = window.onpagehide
						= window.onfocus = window.onblur = onchange;

			   //if tab change happens set status to either hidden or visible
				function onchange (evt) {
					var v = "visible", h = "hidden",
						evtMap = {   //check events and set status based on event type
							focus:v, focusin:v, pageshow:v, blur:h, focusout:h, pagehide:h
						};

					evt = evt || window.event;
					if (evt.type in evtMap) {  // check the title
						currenttitle = oldtitle;
						$(document).attr('title', currenttitle);
					}
					else { // We are in hidden state so create unique title
						currenttitle = this[hidden] ? switchTitle : oldtitle; //update to whatever you want
						$(document).attr('title', currenttitle);
					}

				}

				// set the initial state (but only if browser supports the Page Visibility API)
				if( document[hidden] !== undefined )
					onchange({type: document[hidden] ? "blur" : "focus"});
			})();
		});
  }
}

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 其它&杂项

纯CSS写的支持IE圆角/阴影样式代码

一款支持IE浏览器的圆角代码,让ie6也完美支持IE圆角/阴影等CSS3样式代码。
  其它&杂项
 1561  0

jquery支持按字符数和行数进行截取的查看更多插件

Collapser是一个文本文字截取插件,可按单词数量、字符数量或行截断长文本内容,并使用渐变或幻灯片动画显示/隐藏截断的文本内容。
  其它&杂项
 4582  0

jquery支持多种状态切换的表单按钮生成器插件

一款切换按钮生成器,可将按钮、复选框、单选按钮或选择框转换为带有自定义开/关图标的单状态或多状态切换按钮。
  其它&杂项
 7609  0

jq倒计时10秒延迟跳转

10s倒计时完成后,自动显示“点击进入页面”按钮,点击即可打开连接。
  其它&杂项
 7744  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论