Javascript - 后台窗口来消息时标题栏闪烁

切换背景色
主题: 字体: 切换行号 全选代码块(Ctrl+C复制) 半瓶墨水11个月前贴出, JavaScript 语言
JavaScript代码: Javascript - 后台窗口来消息时标题栏闪烁
01 //from: http://stackoverflow.com/questions/37122/make-browser-window-blink-in-task-bar
02 /*
03 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.
04 */
05 function clear_blink(oldTitle) {
06   clearInterval(g_timeout_id);
07   g_timeout_id = null;
08   document.title = oldTitle;
09   document.onmousemove = null;
10   document.onkeydown = null;
11 }
12 function blink_info(msg) {
13   var oldTitle = document.title;
14   if (typeof(g_timeout_id) != "undefined" && g_timeout_id) {
15     clearInterval(g_timeout_id);
16   }
17   g_timeout_id = setInterval(function() {
18       document.title = document.title == msg ? ' ' : msg;
19     }, 500);
20   document.onmousemove = function() { clear_blink(oldTitle); };
21   document.onkeydown = function() { clear_blink(oldTitle); };
22 }
返回正常查看模式 返回代码发芽网首页