实例制作:右下角弹出类似QQ或MSN消息提示

时间:2007-07-25 13:08:53  来源:  作者:

<SCRIPT language=JavaScript>  Hb5站长资讯e9Q第一天空网络
<!--  Hb5站长资讯e9Q第一天空网络
 Hb5站长资讯e9Q第一天空网络
/**//*  Hb5站长资讯e9Q第一天空网络
*    消息构造  Hb5站长资讯e9Q第一天空网络
*/  Hb5站长资讯e9Q第一天空网络
function CLASS_MSN_MESSAGE(id,width,height,caption,title,message,target,action){  Hb5站长资讯e9Q第一天空网络
    this.id     = id;  Hb5站长资讯e9Q第一天空网络
    this.title  = title;  Hb5站长资讯e9Q第一天空网络
    this.caption= caption;  Hb5站长资讯e9Q第一天空网络
    this.message= message;  Hb5站长资讯e9Q第一天空网络
    this.target = target;  Hb5站长资讯e9Q第一天空网络
    this.action = action;  Hb5站长资讯e9Q第一天空网络
    this.width    = width?width:200;  Hb5站长资讯e9Q第一天空网络
    this.height = height?height:120;  Hb5站长资讯e9Q第一天空网络
    this.timeout= 150;  Hb5站长资讯e9Q第一天空网络
    this.speed    = 20; Hb5站长资讯e9Q第一天空网络
    this.step    = 1; Hb5站长资讯e9Q第一天空网络
    this.right    = screen.width -1;  Hb5站长资讯e9Q第一天空网络
    this.bottom = screen.height; Hb5站长资讯e9Q第一天空网络
    this.left    = this.right - this.width; Hb5站长资讯e9Q第一天空网络
    this.top    = this.bottom - this.height; Hb5站长资讯e9Q第一天空网络
    this.timer    = 0; Hb5站长资讯e9Q第一天空网络
    this.pause    = false;Hb5站长资讯e9Q第一天空网络
    this.close    = false;Hb5站长资讯e9Q第一天空网络
    this.autoHide    = true;Hb5站长资讯e9Q第一天空网络
Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
/**//*  Hb5站长资讯e9Q第一天空网络
*    隐藏消息方法  Hb5站长资讯e9Q第一天空网络
*/  Hb5站长资讯e9Q第一天空网络
CLASS_MSN_MESSAGE.prototype.hide = function(){  Hb5站长资讯e9Q第一天空网络
    if(this.onunload()){  e9Q第一天空网络

        var offset  = this.height>this.bottom-this.top?this.height:this.bottom-this.top; Hb5站长资讯e9Q第一天空网络
        var me  = this;  e9Q第一天空网络

        if(this.timer>0){   Hb5站长资讯e9Q第一天空网络
            window.clearInterval(me.timer);  Hb5站长资讯e9Q第一天空网络
        }  e9Q第一天空网络

        var fun = function(){  Hb5站长资讯e9Q第一天空网络
            if(me.pause==false||me.close){Hb5站长资讯e9Q第一天空网络
                var x  = me.left; Hb5站长资讯e9Q第一天空网络
                var y  = 0; Hb5站长资讯e9Q第一天空网络
                var width = me.width; Hb5站长资讯e9Q第一天空网络
                var height = 0; Hb5站长资讯e9Q第一天空网络
                if(me.offset>0){ Hb5站长资讯e9Q第一天空网络
                    height = me.offset; Hb5站长资讯e9Q第一天空网络
                } Hb5站长资讯e9Q第一天空网络
     Hb5站长资讯e9Q第一天空网络
                y  = me.bottom - height; Hb5站长资讯e9Q第一天空网络
     Hb5站长资讯e9Q第一天空网络
                if(y>=me.bottom){ Hb5站长资讯e9Q第一天空网络
                    window.clearInterval(me.timer);  Hb5站长资讯e9Q第一天空网络
                    me.Pop.hide();  Hb5站长资讯e9Q第一天空网络
                } else { Hb5站长资讯e9Q第一天空网络
                    me.offset = me.offset - me.step;  Hb5站长资讯e9Q第一天空网络
                } Hb5站长资讯e9Q第一天空网络
                me.Pop.show(x,y,width,height);    Hb5站长资讯e9Q第一天空网络
            }             Hb5站长资讯e9Q第一天空网络
        }  e9Q第一天空网络

        this.timer = window.setInterval(fun,this.speed)      Hb5站长资讯e9Q第一天空网络
    }  Hb5站长资讯e9Q第一天空网络
Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
/**//*  Hb5站长资讯e9Q第一天空网络
*    消息卸载事件,可以重写  Hb5站长资讯e9Q第一天空网络
*/  Hb5站长资讯e9Q第一天空网络
CLASS_MSN_MESSAGE.prototype.onunload = function() {  Hb5站长资讯e9Q第一天空网络
    return true;  Hb5站长资讯e9Q第一天空网络
Hb5站长资讯e9Q第一天空网络
/**//*  Hb5站长资讯e9Q第一天空网络
*    消息命令事件,要实现自己的连接,请重写它  Hb5站长资讯e9Q第一天空网络
Hb5站长资讯e9Q第一天空网络
*/  Hb5站长资讯e9Q第一天空网络
CLASS_MSN_MESSAGE.prototype.oncommand = function(){  Hb5站长资讯e9Q第一天空网络
    //this.close = true;Hb5站长资讯e9Q第一天空网络
    this.hide();  Hb5站长资讯e9Q第一天空网络
 window.open("http://www.chinahtml.com");Hb5站长资讯e9Q第一天空网络
   Hb5站长资讯e9Q第一天空网络
} Hb5站长资讯e9Q第一天空网络
/**//*  Hb5站长资讯e9Q第一天空网络
*    消息显示方法  Hb5站长资讯e9Q第一天空网络
*/  Hb5站长资讯e9Q第一天空网络
CLASS_MSN_MESSAGE.prototype.show = function(){  e9Q第一天空网络

    var oPopup = window.createPopup(); //IE5.5+  Hb5站长资讯e9Q第一天空网络
    Hb5站长资讯e9Q第一天空网络
    this.Pop = oPopup;  Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
    var w = this.width;  Hb5站长资讯e9Q第一天空网络
    var h = this.height;  Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
    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'>"  Hb5站长资讯e9Q第一天空网络
        str += "<TABLE style='BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#cfdef4 border=0>"  Hb5站长资讯e9Q第一天空网络
        str += "<TR>"  Hb5站长资讯e9Q第一天空网络
        str += "<TD style='FONT-SIZE: 12px;COLOR: #0f2c8c' width=30 height=24></TD>"  Hb5站长资讯e9Q第一天空网络
        str += "<TD style='PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #1f336b; PADDING-TOP: 4px' vAlign=center width='100%'>" + this.caption + "</TD>"  Hb5站长资讯e9Q第一天空网络
        str += "<TD style='PADDING-RIGHT: 2px; PADDING-TOP: 2px' vAlign=center align=right width=19>"  Hb5站长资讯e9Q第一天空网络
        str += "<SPAN title=关闭 style='FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px' id='btSysClose' >×</SPAN></TD>"  Hb5站长资讯e9Q第一天空网络
        str += "</TR>"  Hb5站长资讯e9Q第一天空网络
        str += "<TR>"  Hb5站长资讯e9Q第一天空网络
        str += "<TD style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px' colSpan=3 height=" + (h-28) + ">"  Hb5站长资讯e9Q第一天空网络
        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>"  Hb5站长资讯e9Q第一天空网络
        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.chinahtml.com' hidefocus=false id='ommand'><FONT color=#ff0000>网页素材下载站</FONT></A></DIV>"  Hb5站长资讯e9Q第一天空网络
        str += "</DIV>"  Hb5站长资讯e9Q第一天空网络
        str += "</TD>"  Hb5站长资讯e9Q第一天空网络
        str += "</TR>"  Hb5站长资讯e9Q第一天空网络
        str += "</TABLE>"  Hb5站长资讯e9Q第一天空网络
        str += "</DIV>"  Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
    oPopup.document.body.innerHTML = str; Hb5站长资讯e9Q第一天空网络
    Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
    this.offset  = 0; Hb5站长资讯e9Q第一天空网络
    var me  = this;  e9Q第一天空网络

    oPopup.document.body.onmouseover = function(){me.pause=true;}Hb5站长资讯e9Q第一天空网络
    oPopup.document.body.onmouseout = function(){me.pause=false;}e9Q第一天空网络

    var fun = function(){  Hb5站长资讯e9Q第一天空网络
        var x  = me.left; Hb5站长资讯e9Q第一天空网络
        var y  = 0; Hb5站长资讯e9Q第一天空网络
        var width    = me.width; Hb5站长资讯e9Q第一天空网络
        var height    = me.height; e9Q第一天空网络

            if(me.offset>me.height){ Hb5站长资讯e9Q第一天空网络
                height = me.height; Hb5站长资讯e9Q第一天空网络
            } else { Hb5站长资讯e9Q第一天空网络
                height = me.offset; Hb5站长资讯e9Q第一天空网络
            } e9Q第一天空网络

        y  = me.bottom - me.offset; Hb5站长资讯e9Q第一天空网络
        if(y<=me.top){ Hb5站长资讯e9Q第一天空网络
            me.timeout--; Hb5站长资讯e9Q第一天空网络
            if(me.timeout==0){ Hb5站长资讯e9Q第一天空网络
                window.clearInterval(me.timer);  Hb5站长资讯e9Q第一天空网络
                if(me.autoHide){Hb5站长资讯e9Q第一天空网络
                    me.hide(); Hb5站长资讯e9Q第一天空网络
                }Hb5站长资讯e9Q第一天空网络
            } Hb5站长资讯e9Q第一天空网络
        } else { Hb5站长资讯e9Q第一天空网络
            me.offset = me.offset + me.step; Hb5站长资讯e9Q第一天空网络
        } Hb5站长资讯e9Q第一天空网络
        me.Pop.show(x,y,width,height);    e9Q第一天空网络

    }  Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
    this.timer = window.setInterval(fun,this.speed)      Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
     Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
    var btClose = oPopup.document.getElementById("btSysClose");  Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
    btClose.onclick = function(){  Hb5站长资讯e9Q第一天空网络
        me.close = true;Hb5站长资讯e9Q第一天空网络
        me.hide();  Hb5站长资讯e9Q第一天空网络
    }  Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
    var btCommand = oPopup.document.getElementById("btCommand");  Hb5站长资讯e9Q第一天空网络
    btCommand.onclick = function(){  Hb5站长资讯e9Q第一天空网络
        me.oncommand();  Hb5站长资讯e9Q第一天空网络
    }    Hb5站长资讯e9Q第一天空网络
  var ommand = oPopup.document.getElementById("ommand");  Hb5站长资讯e9Q第一天空网络
      ommand.onclick = function(){  Hb5站长资讯e9Q第一天空网络
       //this.close = true;Hb5站长资讯e9Q第一天空网络
    me.hide();  Hb5站长资讯e9Q第一天空网络
 window.open(ommand.href);Hb5站长资讯e9Q第一天空网络
    }   Hb5站长资讯e9Q第一天空网络
Hb5站长资讯e9Q第一天空网络
/**//* Hb5站长资讯e9Q第一天空网络
** 设置速度方法 Hb5站长资讯e9Q第一天空网络
**/ Hb5站长资讯e9Q第一天空网络
CLASS_MSN_MESSAGE.prototype.speed = function(s){ Hb5站长资讯e9Q第一天空网络
    var t = 20; Hb5站长资讯e9Q第一天空网络
    try { Hb5站长资讯e9Q第一天空网络
        t = praseInt(s); Hb5站长资讯e9Q第一天空网络
    } catch(e){} Hb5站长资讯e9Q第一天空网络
    this.speed = t; Hb5站长资讯e9Q第一天空网络
} Hb5站长资讯e9Q第一天空网络
/**//* Hb5站长资讯e9Q第一天空网络
** 设置步长方法 Hb5站长资讯e9Q第一天空网络
**/ Hb5站长资讯e9Q第一天空网络
CLASS_MSN_MESSAGE.prototype.step = function(s){ Hb5站长资讯e9Q第一天空网络
    var t = 1; Hb5站长资讯e9Q第一天空网络
    try { Hb5站长资讯e9Q第一天空网络
        t = praseInt(s); Hb5站长资讯e9Q第一天空网络
    } catch(e){} Hb5站长资讯e9Q第一天空网络
    this.step = t; Hb5站长资讯e9Q第一天空网络
} Hb5站长资讯e9Q第一天空网络
  Hb5站长资讯e9Q第一天空网络
CLASS_MSN_MESSAGE.prototype.rect = function(left,right,top,bottom){ Hb5站长资讯e9Q第一天空网络
    try { Hb5站长资讯e9Q第一天空网络
        this.left        = left    !=null?left:this.right-this.width; Hb5站长资讯e9Q第一天空网络
        this.right        = right    !=null?right:this.left +this.width; Hb5站长资讯e9Q第一天空网络
        this.bottom        = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height; Hb5站长资讯e9Q第一天空网络
        this.top        = top    !=null?top:this.bottom - this.height; Hb5站长资讯e9Q第一天空网络
    } catch(e){} Hb5站长资讯e9Q第一天空网络
} Hb5站长资讯e9Q第一天空网络
var MSG1 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有1封消息","懒人图库");  Hb5站长资讯e9Q第一天空网络
    MSG1.rect(null,null,null,screen.height-50); Hb5站长资讯e9Q第一天空网络
    MSG1.speed    = 10; Hb5站长资讯e9Q第一天空网络
    MSG1.step    = 5; Hb5站长资讯e9Q第一天空网络
    //alert(MSG1.top); Hb5站长资讯e9Q第一天空网络
    MSG1.show();  e9Q第一天空网络

//同时两个有闪烁,只能用层代替了,不过层不跨框架 Hb5站长资讯e9Q第一天空网络
//var MSG2 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有2封消息","好的啊");  Hb5站长资讯e9Q第一天空网络
//   MSG2.rect(100,null,null,screen.height); Hb5站长资讯e9Q第一天空网络
//    MSG2.show();  Hb5站长资讯e9Q第一天空网络
//-->  Hb5站长资讯e9Q第一天空网络
</SCRIPT> Hb5站长资讯e9Q第一天空网络
e9Q第一天空网络

文章评论

共有 位天空网友发表了评论 查看完整内容

特别推荐
  • 文字广告
  • 文字广告
  • 文字广告
  • 文字广告
站长黑板报

24小时热门信息