弹出形如MSN和QQ的消息提示框

 下面是一段弹出的主要JS代码
ContractedBlock.gif ExpandedBlockStart.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 
*/
  
None.gif
function CLASS_MSN_MESSAGE(id,width,height,caption,title,message,target,action)  
ExpandedBlockStart.gifContractedBlock.gif
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;
ExpandedBlockEnd.gif}
  
None.gif  
ExpandedBlockStart.gifContractedBlock.gif
/**//*  
InBlock.gif *    隐藏消息方法  
ExpandedBlockEnd.gif 
*/
  
None.gifCLASS_MSN_MESSAGE.prototype.hide 
= function()  
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{  
InBlock.gif    
if(this.onunload())      
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{  
InBlock.gif        
var offset  = this.height>this.bottom-this.top?this.height:this.bottom-this.top; 
InBlock.gif        
var me  = this;  
InBlock.gif 
InBlock.gif        
if(this.timer>0)  
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{   
InBlock.gif            window.clearInterval(me.timer);  
ExpandedSubBlockEnd.gif        }
  
InBlock.gif 
InBlock.gif        
var fun = function()  
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{  
InBlock.gif            
if(me.pause==false)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
var x  = me.left; 
InBlock.gif                
var y  = 0
InBlock.gif                
var width = me.width; 
InBlock.gif                
var height = 0
InBlock.gif                
if(me.offset>0
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif
InBlock.gif                    height 
= me.offset; 
ExpandedSubBlockEnd.gif                }
 
InBlock.gif     
InBlock.gif                y  
= me.bottom - height; 
InBlock.gif     
InBlock.gif                
if(y>=me.bottom) 
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif
InBlock.gif                    window.clearInterval(me.timer);  
InBlock.gif                    me.Pop.hide();  
ExpandedSubBlockEnd.gif                }
 
InBlock.gif                
else 
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif
InBlock.gif                    me.offset 
= me.offset - me.step;  
ExpandedSubBlockEnd.gif                }
 
InBlock.gif                me.Pop.show(x,y,width,height);    
ExpandedSubBlockEnd.gif            }

InBlock.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 
*/
  
None.gifCLASS_MSN_MESSAGE.prototype.onunload 
= function()  
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
return true;  
ExpandedBlockEnd.gif}
  
ExpandedBlockStart.gifContractedBlock.gif
/**//*  
InBlock.gif *    消息命令事件,要实现自己的连接,请重写它  
InBlock.gif *  
ExpandedBlockEnd.gif 
*/
  
None.gifCLASS_MSN_MESSAGE.prototype.oncommand 
= function()  
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{  
InBlock.gif    
//alert("OK");
InBlock.gif
    this.hide();  
ExpandedBlockEnd.gif}
  
None.gif  
ExpandedBlockStart.gifContractedBlock.gif
/**//*  
InBlock.gif *    消息显示方法  
ExpandedBlockEnd.gif 
*/
  
None.gifCLASS_MSN_MESSAGE.prototype.show 
= function()  
ExpandedBlockStart.gifContractedBlock.gif
dot.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=#CEDBF3 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' >x</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
InBlock.gif    
var fun = function()  
ExpandedSubBlockStart.gifContractedSubBlock.gif    
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 
InBlock.gif 
InBlock.gif            
if(me.offset>me.height) 
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif
InBlock.gif                height 
= me.height; 
ExpandedSubBlockEnd.gif            }
 
InBlock.gif            
else 
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif
InBlock.gif                height 
= me.offset; 
ExpandedSubBlockEnd.gif            }
 
InBlock.gif 
InBlock.gif        y  
= me.bottom - me.offset; 
InBlock.gif        
if(y<=me.top) 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif
InBlock.gif            me.timeout
--
InBlock.gif            
if(me.timeout==0
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif
InBlock.gif                window.clearInterval(me.timer);  
InBlock.gif                me.hide(); 
ExpandedSubBlockEnd.gif            }
 
ExpandedSubBlockEnd.gif        }
 
InBlock.gif        
else 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif
InBlock.gif            me.offset 
= me.offset + me.step; 
ExpandedSubBlockEnd.gif        }
 
InBlock.gif        me.Pop.show(x,y,width,height);    
InBlock.gif 
InBlock.gif          
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  
InBlock.gif    btClose.onclick 
= function()  
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{  
InBlock.gif        me.hide();  
ExpandedSubBlockEnd.gif    }
  
InBlock.gif  
InBlock.gif    
var btCommand = oPopup.document.getElementById("btCommand");  
InBlock.gif    btCommand.onclick 
= function()  
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{  
InBlock.gif        me.oncommand();  
ExpandedSubBlockEnd.gif    }
  
InBlock.gif  
InBlock.gif  
ExpandedBlockEnd.gif}
  
ExpandedBlockStart.gifContractedBlock.gif
/**//* 
InBlock.gif** 设置速度方法 
ExpandedBlockEnd.gif*
*/
 
None.gifCLASS_MSN_MESSAGE.prototype.speed 
= function(s) 
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
InBlock.gif    
var t = 20
InBlock.gif    
try 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        t 
= praseInt(s); 
ExpandedSubBlockEnd.gif    }
 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
catch(e)dot.gif{} 
InBlock.gif    
this.speed = t; 
ExpandedBlockEnd.gif}
 
ExpandedBlockStart.gifContractedBlock.gif
/**//* 
InBlock.gif** 设置步长方法 
ExpandedBlockEnd.gif*
*/
 
None.gifCLASS_MSN_MESSAGE.prototype.step 
= function(s) 
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
InBlock.gif    
var t = 1
InBlock.gif    
try 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif
InBlock.gif        t 
= praseInt(s); 
ExpandedSubBlockEnd.gif    }
 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
catch(e)dot.gif{} 
InBlock.gif    
this.step = t; 
ExpandedBlockEnd.gif}
 
None.gif  
None.gifCLASS_MSN_MESSAGE.prototype.rect 
= function(left,right,top,bottom) 
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
InBlock.gif    
try 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
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; 
InBlock.gif 
ExpandedSubBlockEnd.gif    }
 
InBlock.gif    
catch(e) 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{} 
ExpandedBlockEnd.gif}
 
None.gif

在主页面弹出消息
ContractedBlock.gif ExpandedBlockStart.gif
None.gif<script type="text/javascript">
None.gif        
// 主进程
None.gif
        mainLoop();
None.gif        
None.gif        
function mainLoop()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
InBlock.gif            
InBlock.gif            
InBlock.gif            
// 检查最新消息
InBlock.gif
            checkNewMessage();
InBlock.gif            
InBlock.gif            
// 每隔10秒执行一次mainLoop函数
InBlock.gif
            setTimeout("mainLoop()"10000);            
ExpandedBlockEnd.gif        }

None.gif
None.gif 
// 标志发送消息窗口是否打开的变量
None.gif
        var sendWindow = false;
None.gif       
//弹出消息框
None.gif
       function checkNewMessage()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
var MSG1 = new CLASS_MSN_MESSAGE("aa",200,120,"消息提示:",'111+ "说:",'暗暗啊');
InBlock.gif            
InBlock.gif            
// 设置点击提示框消息的响应函数
InBlock.gif
                    MSG1.oncommand = function()
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
if (!sendWindow)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            window.showModelessDialog(
"WebForm2.aspx");
ExpandedSubBlockEnd.gif                        }

InBlock.gif                    
ExpandedSubBlockEnd.gif                    }
;
InBlock.gif                    
InBlock.gif                    
InBlock.gif            MSG1.rect(
null,null,null,screen.height-50); 
InBlock.gif                    MSG1.speed 
= 10
InBlock.gif                    MSG1.step 
= 5
InBlock.gif                    MSG1.show(); 
ExpandedBlockEnd.gif        }

None.gif        
None.gif        
</script>

转载于:https://www.cnblogs.com/huazi4995/archive/2006/11/01/547346.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值