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. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 其它&杂项

jquery带禁止操作的列表穿梭框插件

双列表框之间可使用鼠标单击菜单,进行随意来回穿梭,被屏蔽的列表菜单不可操作。
  其它&杂项
 9858  0

javascript鼠标双击触发文本行内容编辑

一款双击鼠标即可编辑文本文字特效,鼠标双击某些文本文字时,该文本将变为可编辑文本。它使用“contentEditable”属性允许立即编辑内容。
  其它&杂项
 2889  0

jquery所见即所得的CSS生成器插件

把编写css样式代码变成可视化的表单点选操作,很实用的工具!
  其它&杂项
 1638  0

javascript实现在线购物车特效代码

一款简易的js购物车代码,使用了缓存cookies记录存储购物车信息(含价格、名称),单击“清空”按钮即可删除购物车cookie商品数据。
  其它&杂项
 7895  0

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

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