闪烁的标题栏 [英] Flash the title bar

查看:109
本文介绍了闪烁的标题栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让标题栏闪烁,使用非常基本的HTML。我给它一个镜头,但低于code似乎没有工作,我不知道为什么。此外,有没有一种方法,使标题栏Flash文本,但前提是用户没有查看当前浏览页面?

我尝试:

 功能闪光灯(){
            window.setTimeout(函数(){
            警报(document.title时);
                document.title时=(document.title时==公司,公司 - 闪文:本公司);
            },1000);            this.stop =功能(){
                document.title时=公司;
                clearTimeout(this.timer);
            }
        }


解决方案

这其中的让我的浏览器如闪烁指示灯
但因为我写这个剧本现在反正:

 <脚本>
VAR定时器=;
VAR isBlurred = FALSE;
window.onblur =功能(){
  isBlurred = TRUE;
  定时器= window.setInterval(函数(){
    document.title时= document.title时==公司? 公司 - 闪文:公司;
  },1000);
}
window.onfocus =功能(){
  isBlurred = FALSE;
  document.title时=公司;
  clearInterval(定时器);
}
< / SCRIPT>

jQuery的版本是不是真的太大的不同(但不是测试)

  VAR定时器=;
VAR isBlurred = FALSE;
$(窗口)。在(模糊,函数(){
  isBlurred = TRUE;
  定时器= window.setInterval(函数(){
    document.title时= document.title时==公司? 公司 - 闪文:公司;
  },1000);
})。在(焦点访谈,函数(){
  isBlurred = FALSE;
  document.title时=公司;
  clearInterval(定时器);
});

I am try to get the title bar to flash, using very basic HTML. I've given it a shot, but the code below doesn't seem to work, and I have no idea why. Also, is there a way to make the title bar flash text, but only if the user is not viewing the current browser page?

My attempt:

function Flash() {
            window.setTimeout(function() {
            alert(document.title);
                document.title = (document.title == "Company" ? "Company - flash text" : "Company");
            }, 1000);

            this.stop = function() { 
                document.title = "Company";
                clearTimeout(this.timer);
            }
        }

解决方案

duplicate of this one make my browser blink as indicator but since I wrote this script now anyway:

<script>
var timer="";
var isBlurred=false;
window.onblur=function() {
  isBlurred = true;
  timer=window.setInterval(function() {
    document.title = document.title == "Company" ? "Company - flash text" : "Company";
  }, 1000);
}
window.onfocus=function() { 
  isBlurred = false;
  document.title = "Company";
  clearInterval(timer);
}
</script>

jQuery version is not really much different (but not tested)

var timer="";
var isBlurred=false;
$(window).on("blur",function() {
  isBlurred = true;
  timer=window.setInterval(function() {
    document.title = document.title == "Company" ? "Company - flash text" : "Company";
  }, 1000);
}).on("focus",function() { 
  isBlurred = false;
  document.title = "Company";
  clearInterval(timer);
});

这篇关于闪烁的标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆