网页特效观止|CHINAHTML|---页面右下角弹出类似QQ或MSN的消息提示

  1. <HTML><HEAD>   
  2. <TITLE>网页特效观止|CHINAHTML|---页面右下角弹出类似QQ或MSN的消息提示</TITLE>   
  3. <SCRIPT language=JavaScript>     
  4. <!--     
  5.      
  6. /**//*    
  7. **    ============================================================    
  8. **    类名:CLASS_MSN_MESSAGE    
  9. **    功能:提供类似MSN消息框    
  10. **    示例:    
  11.     --------------------------------------------------------------------------------------  
  12.     
  13.             var MSG = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有1封消息","今天请我吃饭哈");    
  14.                 MSG.show();    
  15.     
  16.     -------------------------------------------------------------------------------------  
  17. **    作者:ttyp    
  18. **    邮件:ttyp@21cn.com    
  19. **      
  20. **    ============================================================   
  21. **/     
  22.      
  23.      
  24. /**//*    
  25. *    消息构造    
  26. */     
  27. function CLASS_MSN_MESSAGE(id,width,height,caption,title,message,target,action){     
  28.     this.id     = id;     
  29.     this.title  = title;     
  30.     this.caption= caption;     
  31.     this.message= message;     
  32.     this.target = target;     
  33.     this.action = action;     
  34.     this.width    = width?width:200;     
  35.     this.height = height?height:120;     
  36.     this.timeout= 500;     
  37.     this.speed    = 120;    
  38.     this.step    = 1;    
  39.     this.right    = screen.width -1;     
  40.     this.bottom = screen.height;    
  41.     this.left    = this.right - this.width;    
  42.     this.top    = this.bottom - this.height;    
  43.     this.timer    = 0;    
  44.     this.pause    = false;   
  45.     this.close    = false;   
  46.     this.autoHide    = true;   
  47. }     
  48.      
  49. /**//*    
  50. *    隐藏消息方法    
  51. */     
  52. CLASS_MSN_MESSAGE.prototype.hide = function(){     
  53.     if(this.onunload()){     
  54.   
  55.         var offset  = this.height>this.bottom-this.top?this.height:this.bottom-this.top;    
  56.         var me  = this;     
  57.   
  58.         if(this.timer>0){      
  59.             window.clearInterval(me.timer);     
  60.         }     
  61.   
  62.         var fun = function(){     
  63.             if(me.pause==false||me.close){   
  64.                 var x  = me.left;    
  65.                 var y  = 0;    
  66.                 var width = me.width;    
  67.                 var height = 0;    
  68.                 if(me.offset>0){    
  69.                     height = me.offset;    
  70.                 }    
  71.         
  72.                 y  = me.bottom - height;    
  73.         
  74.                 if(y>=me.bottom){    
  75.                     window.clearInterval(me.timer);     
  76.                     me.Pop.hide();     
  77.                 } else {    
  78.                     me.offset = me.offset - me.step;     
  79.                 }    
  80.                 me.Pop.show(x,y,width,height);       
  81.             }                
  82.         }     
  83.   
  84.         this.timer = window.setInterval(fun,this.speed)         
  85.     }     
  86. }     
  87.      
  88. /**//*    
  89. *    消息卸载事件,可以重写    
  90. */     
  91. CLASS_MSN_MESSAGE.prototype.onunload = function() {     
  92.     return true;     
  93. }     
  94. /**//*    
  95. *    消息命令事件,要实现自己的连接,请重写它    
  96. *    
  97. */     
  98. CLASS_MSN_MESSAGE.prototype.oncommand = function(){     
  99.     //this.close = true;   
  100.     this.hide();     
  101.  window.open("http://www.baidu.com");   
  102.       
  103. }    
  104. /**//*    
  105. *    消息显示方法    
  106. */     
  107. CLASS_MSN_MESSAGE.prototype.show = function(){     
  108.   
  109.     var oPopup = window.createPopup(); //IE5.5+     
  110.        
  111.     this.Pop = oPopup;     
  112.      
  113.     var w = this.width;     
  114.     var h = this.height;     
  115.      
  116.     var str = "<DIV style='BORDER-RIGHT: #455690 1px solid; BORDER-TOP: #a6b4cf 1px solid; Z-INDEX: 99999; LEFT: 0px; BORDER-LEFT: #a6b4cf 1px solid; WIDTH: " + w + "px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: " + h + "px; BACKGROUND-COLOR: #c9d3f3'>"     
  117.         str += "<TABLE style='BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#cfdef4 border=0>"     
  118.         str += "<TR>"     
  119.         str += "<TD style='FONT-SIZE: 12px;COLOR: #0f2c8c' width=30 height=24></TD>"     
  120.         str += "<TD style='PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #1f336b; PADDING-TOP: 4px' vAlign=center width='100%'>" + this.caption + "</TD>"     
  121.         str += "<TD style='PADDING-RIGHT: 2px; PADDING-TOP: 2px' vAlign=center align=right width=19>"     
  122.         str += "<SPAN title=关闭 style='FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px' id='btSysClose' >×</SPAN></TD>"     
  123.         str += "</TR>"     
  124.         str += "<TR>"     
  125.         str += "<TD style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px' colSpan=3 height=" + (h-28) + ">"     
  126.         str += "<DIV style='BORDER-RIGHT: #b9c9ef 1px solid; PADDING-RIGHT: 8px; BORDER-TOP: #728eb8 1px solid; PADDING-LEFT: 8px; FONT-SIZE: 12px; PADDING-BOTTOM: 8px; BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 8px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%'>" + this.title + "<BR><BR>"     
  127.         str += "<DIV style='WORD-BREAK: break-all' align=left><A href='javascript:void(0)' hidefocus=false id='btCommand'><FONT color=#ff0000>" + this.message + "</FONT></A>fghfghfghghghgh<A href='http://www.sohu.com' hidefocus=false id='ommand'><FONT color=#ff0000>dfgdfgfg</FONT></A></DIV>"     
  128.         str += "</DIV>"     
  129.         str += "</TD>"     
  130.         str += "</TR>"     
  131.         str += "</TABLE>"     
  132.         str += "</DIV>"     
  133.      
  134.     oPopup.document.body.innerHTML = str;    
  135.        
  136.      
  137.     this.offset  = 0;    
  138.     var me  = this;     
  139.   
  140.     oPopup.document.body.onmouseover = function(){me.pause=true;}   
  141.     oPopup.document.body.onmouseout = function(){me.pause=false;}   
  142.   
  143.     var fun = function(){     
  144.         var x  = me.left;    
  145.         var y  = 0;    
  146.         var width    = me.width;    
  147.         var height    = me.height;    
  148.   
  149.             if(me.offset>me.height){    
  150.                 height = me.height;    
  151.             } else {    
  152.                 height = me.offset;    
  153.             }    
  154.   
  155.         y  = me.bottom - me.offset;    
  156.         if(y<=me.top){    
  157.             me.timeout--;    
  158.             if(me.timeout==0){    
  159.                 window.clearInterval(me.timer);     
  160.                 if(me.autoHide){   
  161.                     me.hide();    
  162.                 }   
  163.             }    
  164.         } else {    
  165.             me.offset = me.offset + me.step;    
  166.         }    
  167.         me.Pop.show(x,y,width,height);       
  168.   
  169.     }     
  170.      
  171.     this.timer = window.setInterval(fun,this.speed)         
  172.      
  173.         
  174.      
  175.     var btClose = oPopup.document.getElementById("btSysClose");     
  176.      
  177.     btClose.onclick = function(){     
  178.         me.close = true;   
  179.         me.hide();     
  180.     }     
  181.      
  182.     var btCommand = oPopup.document.getElementById("btCommand");     
  183.     btCommand.onclick = function(){     
  184.         me.oncommand();     
  185.     }       
  186.   var ommand = oPopup.document.getElementById("ommand");     
  187.       ommand.onclick = function(){     
  188.        //this.close = true;   
  189.     me.hide();     
  190.  window.open(ommand.href);   
  191.     }      
  192. }     
  193. /**//*   
  194. ** 设置速度方法   
  195. **/    
  196. CLASS_MSN_MESSAGE.prototype.speed = function(s){    
  197.     var t = 20;    
  198.     try {    
  199.         t = praseInt(s);    
  200.     } catch(e){}    
  201.     this.speed = t;    
  202. }    
  203. /**//*   
  204. ** 设置步长方法   
  205. **/    
  206. CLASS_MSN_MESSAGE.prototype.step = function(s){    
  207.     var t = 1;    
  208.     try {    
  209.         t = praseInt(s);    
  210.     } catch(e){}    
  211.     this.step = t;    
  212. }    
  213.      
  214. CLASS_MSN_MESSAGE.prototype.rect = function(left,right,top,bottom){    
  215.     try {    
  216.         this.left        = left    !=null?left:this.right-this.width;    
  217.         this.right        = right    !=null?right:this.left +this.width;    
  218.         this.bottom        = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height;    
  219.         this.top        = top    !=null?top:this.bottom - this.height;    
  220.     } catch(e){}    
  221. }    
  222. var MSG1 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有1封消息","今天请我吃饭哈");     
  223.     MSG1.rect(null,null,null,screen.height-50);    
  224.     MSG1.speed    = 10;    
  225.     MSG1.step    = 5;    
  226.     //alert(MSG1.top);    
  227.     MSG1.show();     
  228.   
  229. //同时两个有闪烁,只能用层代替了,不过层不跨框架    
  230. //var MSG2 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有2封消息","好的啊");     
  231. //   MSG2.rect(100,null,null,screen.height);    
  232. //    MSG2.show();     
  233. //-->     
  234. </SCRIPT>    
  235.   
  236. <META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>    
  237. <BODY></BODY></HTML>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值