浏览器闪烁页面标题进行提醒(转载)

var titleInit = document.title,

isShine = true;

setInterval(function () {

var title = document.title;

if (isShine == true) {

if (/新/.test(title) == false) {

document.title = '【你有新消息】';

} else {

document.title = '【     】';

}

} else {

document.title = titleInit;

}

}, 500);

window.onfocus = function () {

isShine = false;

};

window.onblur = function () {

isShine = true;

};

// for IE

document.onfocusin = function () {

isShine = false;

};

document.onfocusout = function () {

isShine = true;

};

你可能感兴趣的:(浏览器闪烁页面标题进行提醒(转载))