类似MSN消息框

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值