Home > Article > Web Front-end > JS realizes the flashing title message reminder effect_javascript skills
Sometimes we need to remind users that there is new news. This can be achieved using the following method.
The effect is that when the web page window does not gain focus and is minimized, the title bar "title" of the web page window displays the content of "[ ]" and "[New Message]".
<script language="JavaScript"> setTimeout('flash_title()',2000); //2秒之后调用一次 function flash_title() { //当窗口效果为最小化,或者没焦点状态下才闪动 if(isMinStatus() || !window.focus) { newMsgCount(); } else { document.title='订单管理中心-AOOXING';//窗口没有消息的时候默认的title内容 window.clearInterval(); } } //消息提示 var flag=false; function newMsgCount(){ if(flag){ flag=false; document.title='【新订单】'; }else{ flag=true; document.title='【 】'; } window.setTimeout('flash_title(0)',380); } //判断窗口是否最小化 //在Opera中还不能显示 var isMin = false; function isMinStatus() { //除了Internet Explorer浏览器,其他主流浏览器均支持Window outerHeight 和outerWidth 属性 if(window.outerWidth != undefined && window.outerHeight != undefined){ isMin = window.outerWidth <= 160 && window.outerHeight <= 27; }else{ isMin = window.outerWidth <= 160 && window.outerHeight <= 27; } //除了Internet Explorer浏览器,其他主流浏览器均支持Window screenY 和screenX 属性 if(window.screenY != undefined && window.screenX != undefined ){ isMin = window.screenY < -30000 && window.screenX < -30000;//FF Chrome }else{ isMin = window.screenTop < -30000 && window.screenLeft < -30000;//IE } return isMin; } </script>