MSN消息提示类

  • 纯js编写
  • 跨框架
  • 无图片
  • 支持调速度
  • 任意位置弹出
  • 需要ie5.5以上
None.gif < HTML >< HEAD >
None.gif
< SCRIPTlanguage = 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.gifvarMSG=newCLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有1封消息","今天请我吃饭哈");
InBlock.gifMSG.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
varoffset=this.height>this.bottom-this.top?this.height:this.bottom-this.top;
InBlock.gif
varme=this;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(this.timer>0)dot.gif{
InBlock.gifwindow.clearInterval(me.timer);
ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
varfun=function()dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(me.pause==false||me.close)dot.gif{
InBlock.gif
varx=me.left;
InBlock.gif
vary=0;
InBlock.gif
varwidth=me.width;
InBlock.gif
varheight=0;
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(me.offset>0)dot.gif{
InBlock.gifheight
=me.offset;
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gify
=me.bottom-height;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(y>=me.bottom)dot.gif{
InBlock.gifwindow.clearInterval(me.timer);
InBlock.gifme.Pop.hide();
ExpandedSubBlockStart.gifContractedSubBlock.gif}
elsedot.gif{
InBlock.gifme.offset
=me.offset-me.step;
ExpandedSubBlockEnd.gif}

InBlock.gifme.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
returntrue;
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
varoPopup=window.createPopup();//IE5.5+
InBlock.gif

InBlock.gif
this.Pop=oPopup;
InBlock.gif
InBlock.gif
varw=this.width;
InBlock.gif
varh=this.height;
InBlock.gif
InBlock.gif
varstr="<DIVstyle='BORDER-RIGHT:#4556901pxsolid;BORDER-TOP:#a6b4cf1pxsolid;Z-INDEX:99999;LEFT:0px;BORDER-LEFT:#a6b4cf1pxsolid;WIDTH:"+w+"px;BORDER-BOTTOM:#4556901pxsolid;POSITION:absolute;TOP:0px;HEIGHT:"+h+"px;BACKGROUND-COLOR:#c9d3f3'>"
InBlock.gifstr
+="<TABLEstyle='BORDER-TOP:#ffffff1pxsolid;BORDER-LEFT:#ffffff1pxsolid'cellSpacing=0cellPadding=0width='100%'bgColor=#cfdef4border=0>"
InBlock.gifstr
+="<TR>"
InBlock.gifstr
+="<TDstyle='FONT-SIZE:12px;COLOR:#0f2c8c'width=30height=24></TD>"
InBlock.gifstr
+="<TDstyle='PADDING-LEFT:4px;FONT-WEIGHT:normal;FONT-SIZE:12px;COLOR:#1f336b;PADDING-TOP:4px'vAlign=centerwidth='100%'>"+this.caption+"</TD>"
InBlock.gifstr
+="<TDstyle='PADDING-RIGHT:2px;PADDING-TOP:2px'vAlign=centeralign=rightwidth=19>"
InBlock.gifstr
+="<SPANtitle= 关闭style='FONT-WEIGHT:bold;FONT- SIZE:12px;CURSOR:hand;COLOR:red;MARGIN-RIGHT:4px'id='btSysClose'>×</SPAN></TD>"
InBlock.gifstr
+="</TR>"
InBlock.gifstr
+="<TR>"
InBlock.gifstr
+="<TDstyle='PADDING-RIGHT:1px;PADDING-BOTTOM:1px'colSpan=3height="+(h-28)+">"
InBlock.gifstr
+="<DIVstyle='BORDER-RIGHT:#b9c9ef1pxsolid;PADDING-RIGHT:8px;BORDER-TOP:#728eb81pxsolid;PADDING-LEFT:8px;FONT-SIZE:12px;PADDING-BOTTOM:8px;BORDER-LEFT:#728eb81pxsolid;WIDTH:100%;COLOR:#1f336b;PADDING-TOP:8px;BORDER-BOTTOM:#b9c9ef1pxsolid;HEIGHT:100%'>"+this.title+"<BR><BR>"
InBlock.gifstr
+="<DIVstyle='WORD-BREAK:break-all'align=left><Ahref='javascript:void(0)'hidefocus=trueid='btCommand'><FONTcolor=#ff0000>"+this.message+"</FONT></A></DIV>"
InBlock.gifstr
+="</DIV>"
InBlock.gifstr
+="</TD>"
InBlock.gifstr
+="</TR>"
InBlock.gifstr
+="</TABLE>"
InBlock.gifstr
+="</DIV>"
InBlock.gif
InBlock.gifoPopup.document.body.innerHTML
=str;
InBlock.gif
InBlock.gif
InBlock.gif
this.offset=0;
InBlock.gif
varme=this;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gifoPopup.document.body.onmouseover
=function()dot.gif{me.pause=true;}
ExpandedSubBlockStart.gifContractedSubBlock.gifoPopup.document.body.onmouseout
=function()dot.gif{me.pause=false;}
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
varfun=function()dot.gif{
InBlock.gif
varx=me.left;
InBlock.gif
vary=0;
InBlock.gif
varwidth=me.width;
InBlock.gif
varheight=me.height;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(me.offset>me.height)dot.gif{
InBlock.gifheight
=me.height;
ExpandedSubBlockStart.gifContractedSubBlock.gif}
elsedot.gif{
InBlock.gifheight
=me.offset;
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gify
=me.bottom-me.offset;
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(y<=me.top)dot.gif{
InBlock.gifme.timeout
--;
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(me.timeout==0)dot.gif{
InBlock.gifwindow.clearInterval(me.timer);
ExpandedSubBlockStart.gifContractedSubBlock.gif
if(me.autoHide)dot.gif{
InBlock.gifme.hide();
ExpandedSubBlockEnd.gif}

ExpandedSubBlockEnd.gif}

ExpandedSubBlockStart.gifContractedSubBlock.gif}
elsedot.gif{
InBlock.gifme.offset
=me.offset+me.step;
ExpandedSubBlockEnd.gif}

InBlock.gifme.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
varbtClose=oPopup.document.getElementById("btSysClose");
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gifbtClose.onclick
=function()dot.gif{
InBlock.gifme.close
=true;
InBlock.gifme.hide();
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gif
varbtCommand=oPopup.document.getElementById("btCommand");
ExpandedSubBlockStart.gifContractedSubBlock.gifbtCommand.onclick
=function()dot.gif{
InBlock.gifme.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
vart=20;
ExpandedSubBlockStart.gifContractedSubBlock.gif
trydot.gif{
InBlock.gift
=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
vart=1;
ExpandedSubBlockStart.gifContractedSubBlock.gif
trydot.gif{
InBlock.gift
=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
trydot.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.gifMSG1.rect(
null , null , null ,screen.height - 50 );
None.gifMSG1.speed
= 10 ;
None.gifMSG1.step
= 5 ;
None.gif
// alert(MSG1.top);
None.gif
MSG1.show();
None.gif
None.gif
// 同时两个有闪烁,只能用层代替了,不过层不跨框架
None.gif//
varMSG2=newCLASS_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
< METAcontent = " MSHTML6.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、付费专栏及课程。

余额充值