浏览器标题闪烁功能
浏览器窗体获得焦点则停止标题闪烁通知,失去焦点则开启标题闪烁通知
功能描述
窗体失焦的时候,标题就会闪
补充说明:
浏览器窗体获得焦点和失去焦点,Chrome和FireFox浏览器是window的onfocus,
onblur方法;而IE浏览器则是document的onfocusin, onfocusout方法
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>标签页标题闪烁</title></head><body><h2>浏览器窗体标题闪烁通知</h2><script>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;}}, 1000);// for Chrome and FireFoxwindow.onfocus = function () {console.log(123);isShine = false;};window.onblur = function () {isShine = true;};// for IEdocument.onfocusin = function () {isShine = false;};document.onfocusout = function () {isShine = true;};</script></body></html>