使用方法
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. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服