加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – 如果有未读电子邮件,如何使屏幕闪烁

发布时间:2020-12-14 22:50:05 所属栏目:资源 来源:网络整理
导读:当有未读的电子邮件时,我正在寻找使整个屏幕闪烁红色或任何颜色的任何方法.它可以用于任何电子邮件客户端.我做了很多谷歌搜索,找不到任何东西.雷鸟的附加组件会产生一些闪烁的通知,但它只会在屏幕的右下角显得非常小. 我想到的可能是Firefox或Chrome的一些附

当有未读的电子邮件时,我正在寻找使整个屏幕闪烁红色或任何颜色的任何方法.它可以用于任何电子邮件客户端.我做了很多谷歌搜索,找不到任何东西.雷鸟的附加组件会产生一些闪烁的通知,但它只会在屏幕的右下角显得非常小.

我想到的可能是Firefox或Chrome的一些附加组件,它允许我编写可在Gmail上运行的自定义css和javascript,并使闪烁发生.
任何想法都非常感谢.

我知道这不是你经常提出的问题,但你们都很棒,我不知道还有什么地方可以转.如果有一个更好的论坛可以解决这类问题,你也可以告诉我.

谢谢!

最佳答案
我不是制作Chrome插件,而是让窗口标题闪烁或使用HTML5通知.创建一个简单页面,轮询您的IMAP Gmail以获取新邮件,并在大型iFrame中包含Gmail.如果找到新消息,则外部窗口可以发出通知.

HTML5通知:http://www.html5rocks.com/en/tutorials/notifications/quick/

闪烁标题(从this采用):

var newMailBlinker = (function () {
    var oldTitle = document.title,msg = 'New Mail!',timeoutId,blink = function() { 
            document.title = document.title == msg ? ' ' : msg; 
        },clear = function() {
            clearInterval(timeoutId);
            document.title = oldTitle;
            window.onmousemove = null;
            timeoutId = null;
        };

    return function () {
        if (!timeoutId) {
            timeoutId = setInterval(blink,1000);
            window.onmousemove = clear;
        }
    };
}());

PHP民意调查Gmail IMAP(从this采用):

$t1=time();//mark time in
$tt=$t1+(60*1);//total time = t1 + n seconds

do{
    if(isset($t2)) unset($t2);//clean it at every loop cicle
    $t2=time();//mark time
    if(imap_num_msg($imap)!=0){//if there is any message (in the inbox)

        $mc=imap_check($imap);//messages check
        //var_dump($mc); die;//vardump it to see all the data it is possible to get with imap_check() and them customize it for yourself
        echo 'New messages available';

    }else echo 'No new messagens';

    sleep(rand(7,13));//Give Google server a breack
    if(!@imap_ping($imap)){//if the connection is not up
        //start the imap connection the normal way like you did at first
    }

}while($tt>$t2);//if the total time was not achivied yet,get back to the beginning of the loop

jQuery AJAX轮询到您的IMAP脚本(从this采用):

// make the AJAX request
function ajax_request() {
  $.ajax({
    url: '/path/to/gmail/imap/checkMessages.php',dataType: 'json',error: function(xhr_data) {
      // terminate the script
    },success: function(xhr_data) {
        console.log(xhr_data);
        if (xhr_data.status == 'No new messages') {
            setTimeout(function() { ajax_request(); },15000); // wait 15 seconds than call ajax request again
        } else {
            newMailBlinker(); // blink the title here for new messages
        }
    }
    contentType: 'application/json'
  });
}

显然你不会使用jQuery和PHP进行轮询.选择一个进行投票.我建议让客户端进行轮询,并在每次连接时检查一次IMAP.话虽这么说,这些片段应该让你开始:)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读