使任务栏的浏览器窗口闪烁 [英] Make browser window blink in task Bar

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

问题描述

如何让用户的浏览器闪烁/闪光灯/高在使用JavaScript任务栏?例如,如果我做每10秒一个AJAX请求,看看用户是否具有在服务器上的任何新的消息,我希望用户知道它了,即使他当时使用其他应用程序。

How do I make a user's browser blink/flash/highlight in the task bar using JavaScript? For example, if I make an AJAX request every 10 seconds to see if the user has any new messages on the server, I want the user to know it right away, even if he is using another application at the time.

编辑:这些用户希望被分心,当新邮件到达

推荐答案

这不会使颜色改变任务栏按钮闪烁,但标题将闪烁和关闭,直到他们移动鼠标。这应该工作的跨平台的,即使他们只是在一个不同的标签。

this won't make the taskbar button flash in changing colours, but the title will blink on and off until they move the mouse. This should work cross platform, and even if they just have it in a different tab.

newExcitingAlerts = (function () {
    var oldTitle = document.title;
    var msg = "New!";
    var timeoutId;
    var blink = function() { document.title = document.title == msg ? ' ' : msg; };
    var clear = function() {
        clearInterval(timeoutId);
        document.title = oldTitle;
        window.onmousemove = null;
        timeoutId = null;
    };
    return function () {
        if (!timeoutId) {
            timeoutId = setInterval(blink, 1000);
            window.onmousemove = clear;
        }
    };
}());


更新的:你可能想看看使用 HTML5通知


Update: You may want to look at using HTML5 notifications.

这篇关于使任务栏的浏览器窗口闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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