类似开心网的信息提示

<!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 onload="init();">  
    <center>  
        <input type="button" value="begin" onclick="begin();"/>  
        <input type="button" value="end" onclick="end();"/>  
        <br/>  
        coloryeah - 为意识增添色彩!   
    </center>  
 </BODY>  
</HTML>  

你可能感兴趣的:(java,html)