类似于开心网消息提醒功能

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>测试页面</TITLE>
<script type="text/javascript">
    var dynamicMsg = null;
    function init() {  
        dynamicMsg = new DynamicMessage(window.document.title, "【HI,消息】", "【     】");
    }  

    function begin() {  
        dynamicMsg.initIntervalMsg();
    }  

    function end() {  
        dynamicMsg.clearIntervalMsg();  
    }
    /**  
      * 处理新消息提示的操作  
      */  
      function DynamicMessage(defaultMsg, msg, hiddenMsg) {  
        this.initIntervalMsg = function() {  
            this.intervalMsg = setInterval(function() {  
                    if(!this.bMsg) {  
                        window.document.title = msg + " - " + defaultMsg;  
                        this.bMsg = true;  
                    } else {  
                        window.document.title = hiddenMsg + " - " + defaultMsg;  
                        this.bMsg = false;  
                    }
                },
                1000  
              );  
          };  
            
          this.clearIntervalMsg = function() {  
            if(this.intervalMsg != null) {  
                clearInterval(this.intervalMsg);  
                window.document.title = defaultMsg;  
                this.bMsg = false;  
            }  
          };  
      }  
</script>
</HEAD>
<BODY οnlοad="init();">
    <center>
        <input type="button" value="begin" οnclick="begin();"/>
        <input type="button" value="end" οnclick="end();"/>
        <br/>
        coloryeah - 为意识增添色彩!  
    </center>
</BODY>
</HTML>

开心网上的代码和这不大一样,这是用js类的思想做的,开心网上的只有2个函数吧。想了好久也没实现来消息的时候,不是活动页面的情况下,在任务栏闪烁,类似QQ那种,js估计是控制不了,得用activeX吧。对this理解不深的可以看看前面介绍this用法的文章。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值