MSN消息提示类(II)

  • 纯js编写
  • 跨框架
  • 无图片
  • 支持调速度
  • 任意位置弹出
  • 需要ie5.5以上
None.gif < HTML >< HEAD >  
None.gif
< SCRIPT language = JavaScript >   
None.gif
<!--   
None.gif  
ExpandedBlockStart.gifContractedBlock.gif
/**/ /*  
InBlock.gif**    ==================================================================================================  
InBlock.gif**    类名:CLASS_MSN_MESSAGE  
InBlock.gif**    功能:提供类似MSN消息框  
InBlock.gif**    示例:  
InBlock.gif    ---------------------------------------------------------------------------------------------------  
InBlock.gif  
InBlock.gif            var MSG = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有1封消息","今天请我吃饭哈");  
InBlock.gif                MSG.show();  
InBlock.gif  
InBlock.gif    ---------------------------------------------------------------------------------------------------  
InBlock.gif**    作者:ttyp  
InBlock.gif**    邮件:ttyp@21cn.com  
InBlock.gif**    日期:2005-3-18  
InBlock.gif**    ==================================================================================================  
ExpandedBlockEnd.gif*
*/
  
None.gif  
None.gif  
ExpandedBlockStart.gifContractedBlock.gif
/**/ /*  
InBlock.gif *    消息构造  
ExpandedBlockEnd.gif 
*/
  
ExpandedBlockStart.gifContractedBlock.gif
function  CLASS_MSN_MESSAGE(id,width,height,caption,title,message,target,action) dot.gif {  
InBlock.gif    
this.id     = id;  
InBlock.gif    
this.title  = title;  
InBlock.gif    
this.caption= caption;  
InBlock.gif    
this.message= message;  
InBlock.gif    
this.target = target;  
InBlock.gif    
this.action = action;  
InBlock.gif    
this.width    = width?width:200;  
InBlock.gif    
this.height = height?height:120;  
InBlock.gif    
this.timeout= 150;  
InBlock.gif    
this.speed    = 20
InBlock.gif    
this.step    = 1
InBlock.gif    
this.right    = screen.width -1;  
InBlock.gif    
this.bottom = screen.height; 
InBlock.gif    
this.left    = this.right - this.width; 
InBlock.gif    
this.top    = this.bottom - this.height; 
InBlock.gif    
this.timer    = 0
InBlock.gif    
this.pause    = false;
InBlock.gif    
this.close    = false;
InBlock.gif    
this.autoHide    = true;
ExpandedBlockEnd.gif}
  
None.gif  
ExpandedBlockStart.gifContractedBlock.gif
/**/ /*  
InBlock.gif *    隐藏消息方法  
ExpandedBlockEnd.gif 
*/
  
ExpandedBlockStart.gifContractedBlock.gifCLASS_MSN_MESSAGE.prototype.hide 
=   function () dot.gif {  
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if(this.onunload())dot.gif{  
InBlock.gif
InBlock.gif        
var offset  = this.height>this.bottom-this.top?this.height:this.bottom-this.top; 
InBlock.gif        
var me  = this;  
InBlock.gif 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
if(this.timer>0)dot.gif{   
InBlock.gif            window.clearInterval(me.timer);  
ExpandedSubBlockEnd.gif        }
  
InBlock.gif 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
var fun = function()dot.gif{  
ExpandedSubBlockStart.gifContractedSubBlock.gif            
if(me.pause==false||me.close)dot.gif{
InBlock.gif                
var x  = me.left; 
InBlock.gif                
var y  = 0
InBlock.gif                
var width = me.width; 
InBlock.gif                
var height = 0
ExpandedSubBlockStart.gifContractedSubBlock.gif                
if(me.offset>0)dot.gif
InBlock.gif                    height 
= me.offset; 
ExpandedSubBlockEnd.gif                }
 
InBlock.gif     
InBlock.gif                y  
= me.bottom - height; 
InBlock.gif     
ExpandedSubBlockStart.gifContractedSubBlock.gif                
if(y>=me.bottom)dot.gif
InBlock.gif                    window.clearInterval(me.timer);  
InBlock.gif                    me.Pop.hide();  
ExpandedSubBlockStart.gifContractedSubBlock.gif                }
 else dot.gif
InBlock.gif                    me.offset 
= me.offset - me.step;  
ExpandedSubBlockEnd.gif                }
 
InBlock.gif                me.Pop.show(x,y,width,height);    
ExpandedSubBlockEnd.gif            }
             
ExpandedSubBlockEnd.gif        }
  
InBlock.gif 
InBlock.gif        
this.timer = window.setInterval(fun,this.speed)      
ExpandedSubBlockEnd.gif    }
  
ExpandedBlockEnd.gif}
  
None.gif  
ExpandedBlockStart.gifContractedBlock.gif
/**/ /*  
InBlock.gif *    消息卸载事件,可以重写  
ExpandedBlockEnd.gif 
*/
  
ExpandedBlockStart.gifContractedBlock.gifCLASS_MSN_MESSAGE.prototype.onunload 
=   function ()  dot.gif {  
InBlock.gif    
return true;  
ExpandedBlockEnd.gif}
  
ExpandedBlockStart.gifContractedBlock.gif
/**/ /*  
InBlock.gif *    消息命令事件,要实现自己的连接,请重写它  
InBlock.gif *  
ExpandedBlockEnd.gif 
*/
  
ExpandedBlockStart.gifContractedBlock.gifCLASS_MSN_MESSAGE.prototype.oncommand 
=   function () dot.gif {  
InBlock.gif    
this.close = true;
InBlock.gif    
this.hide();  
ExpandedBlockEnd.gif}
  
None.gif  
ExpandedBlockStart.gifContractedBlock.gif
/**/ /*  
InBlock.gif *    消息显示方法  
ExpandedBlockEnd.gif 
*/
  
ExpandedBlockStart.gifContractedBlock.gifCLASS_MSN_MESSAGE.prototype.show 
=   function () dot.gif {  
InBlock.gif
InBlock.gif    
var oPopup = window.createPopup(); //IE5.5+  
InBlock.gif
    
InBlock.gif    
this.Pop = oPopup;  
InBlock.gif  
InBlock.gif    
var w = this.width;  
InBlock.gif    
var h = this.height;  
InBlock.gif  
InBlock.gif    
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'>"  
InBlock.gif        str 
+= "<TABLE style='BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#cfdef4 border=0>"  
InBlock.gif        str 
+= "<TR>"  
InBlock.gif        str 
+= "<TD style='FONT-SIZE: 12px;COLOR: #0f2c8c' width=30 height=24></TD>"  
InBlock.gif        str 
+= "<TD style='PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #1f336b; PADDING-TOP: 4px' vAlign=center width='100%'>" + this.caption + "</TD>"  
InBlock.gif        str 
+= "<TD style='PADDING-RIGHT: 2px; PADDING-TOP: 2px' vAlign=center align=right width=19>"  
InBlock.gif        str 
+= "<SPAN title=关闭 style='FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px' id='btSysClose' >×</SPAN></TD>"  
InBlock.gif        str 
+= "</TR>"  
InBlock.gif        str 
+= "<TR>"  
InBlock.gif        str 
+= "<TD style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px' colSpan=3 height=" + (h-28+ ">"  
InBlock.gif        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>"  
InBlock.gif        str 
+= "<DIV style='WORD-BREAK: break-all' align=left><A href='javascript:void(0)' hidefocus=true id='btCommand'><FONT color=#ff0000>" + this.message + "</FONT></A></DIV>"  
InBlock.gif        str 
+= "</DIV>"  
InBlock.gif        str 
+= "</TD>"  
InBlock.gif        str 
+= "</TR>"  
InBlock.gif        str 
+= "</TABLE>"  
InBlock.gif        str 
+= "</DIV>"  
InBlock.gif  
InBlock.gif    oPopup.document.body.innerHTML 
= str; 
InBlock.gif    
InBlock.gif  
InBlock.gif    
this.offset  = 0
InBlock.gif    
var me  = this;  
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    oPopup.document.body.onmouseover 
= function()dot.gif{me.pause=true;}
ExpandedSubBlockStart.gifContractedSubBlock.gif    oPopup.document.body.onmouseout 
= function()dot.gif{me.pause=false;}
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
var fun = function()dot.gif{  
InBlock.gif        
var x  = me.left; 
InBlock.gif        
var y  = 0
InBlock.gif        
var width    = me.width; 
InBlock.gif        
var height    = me.height; 
InBlock.gif 
ExpandedSubBlockStart.gifContractedSubBlock.gif            
if(me.offset>me.height)dot.gif
InBlock.gif                height 
= me.height; 
ExpandedSubBlockStart.gifContractedSubBlock.gif            }
 else dot.gif
InBlock.gif                height 
= me.offset; 
ExpandedSubBlockEnd.gif            }
 
InBlock.gif 
InBlock.gif        y  
= me.bottom - me.offset; 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
if(y<=me.top)dot.gif
InBlock.gif            me.timeout
--
ExpandedSubBlockStart.gifContractedSubBlock.gif            
if(me.timeout==0)dot.gif
InBlock.gif                window.clearInterval(me.timer);  
ExpandedSubBlockStart.gifContractedSubBlock.gif                
if(me.autoHide)dot.gif{
InBlock.gif                    me.hide(); 
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }
 
ExpandedSubBlockStart.gifContractedSubBlock.gif        }
 else dot.gif
InBlock.gif            me.offset 
= me.offset + me.step; 
ExpandedSubBlockEnd.gif        }
 
InBlock.gif        me.Pop.show(x,y,width,height);    
InBlock.gif 
ExpandedSubBlockEnd.gif    }
  
InBlock.gif  
InBlock.gif    
this.timer = window.setInterval(fun,this.speed)      
InBlock.gif  
InBlock.gif     
InBlock.gif  
InBlock.gif    
var btClose = oPopup.document.getElementById("btSysClose");  
InBlock.gif  
ExpandedSubBlockStart.gifContractedSubBlock.gif    btClose.onclick 
= function()dot.gif{  
InBlock.gif        me.close 
= true;
InBlock.gif        me.hide();  
ExpandedSubBlockEnd.gif    }
  
InBlock.gif  
InBlock.gif    
var btCommand = oPopup.document.getElementById("btCommand");  
ExpandedSubBlockStart.gifContractedSubBlock.gif    btCommand.onclick 
= function()dot.gif{  
InBlock.gif        me.oncommand();  
ExpandedSubBlockEnd.gif    }
    
ExpandedBlockEnd.gif}
  
ExpandedBlockStart.gifContractedBlock.gif
/**/ /* 
InBlock.gif** 设置速度方法 
ExpandedBlockEnd.gif*
*/
 
ExpandedBlockStart.gifContractedBlock.gifCLASS_MSN_MESSAGE.prototype.speed 
=   function (s) dot.gif
InBlock.gif    
var t = 20
ExpandedSubBlockStart.gifContractedSubBlock.gif    
try dot.gif
InBlock.gif        t 
= praseInt(s); 
ExpandedSubBlockStart.gifContractedSubBlock.gif    }
 catch(e)dot.gif{} 
InBlock.gif    
this.speed = t; 
ExpandedBlockEnd.gif}
 
ExpandedBlockStart.gifContractedBlock.gif
/**/ /* 
InBlock.gif** 设置步长方法 
ExpandedBlockEnd.gif*
*/
 
ExpandedBlockStart.gifContractedBlock.gifCLASS_MSN_MESSAGE.prototype.step 
=   function (s) dot.gif
InBlock.gif    
var t = 1
ExpandedSubBlockStart.gifContractedSubBlock.gif    
try dot.gif
InBlock.gif        t 
= praseInt(s); 
ExpandedSubBlockStart.gifContractedSubBlock.gif    }
 catch(e)dot.gif{} 
InBlock.gif    
this.step = t; 
ExpandedBlockEnd.gif}
 
None.gif  
ExpandedBlockStart.gifContractedBlock.gifCLASS_MSN_MESSAGE.prototype.rect 
=   function (left,right,top,bottom) dot.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
try dot.gif
InBlock.gif        
this.left        = left    !=null?left:this.right-this.width; 
InBlock.gif        
this.right        = right    !=null?right:this.left +this.width; 
InBlock.gif        
this.bottom        = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height; 
InBlock.gif        
this.top        = top    !=null?top:this.bottom - this.height; 
ExpandedSubBlockStart.gifContractedSubBlock.gif    }
 catch(e)dot.gif{} 
ExpandedBlockEnd.gif}
 
None.gif
var  MSG1  =   new  CLASS_MSN_MESSAGE( " aa " , 200 , 120 , " 短消息提示: " , " 您有1封消息 " , " 今天请我吃饭哈 " );  
None.gif    MSG1.rect(
null , null , null ,screen.height - 50 ); 
None.gif    MSG1.speed    
=   10
None.gif    MSG1.step    
=   5
None.gif    
// alert(MSG1.top); 
None.gif
    MSG1.show();  
None.gif 
None.gif
// 同时两个有闪烁,只能用层代替了,不过层不跨框架 
None.gif//
var MSG2 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有2封消息","好的啊");  
None.gif//
   MSG2.rect(100,null,null,screen.height); 
None.gif//
    MSG2.show();  
None.gif//
-->  
None.gif
</ SCRIPT >  
None.gif 
None.gif
< META content = " MSHTML 6.00.2800.1106 "  name = GENERATOR ></ HEAD >  
None.gif
< BODY ></ BODY ></ HTML >  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值