实例制作:右下角弹出类似QQ或MSN消息提示
<SCRIPT language=JavaScript> Hb5站长资讯
<!-- Hb5站长资讯
Hb5站长资讯
/**//* Hb5站长资讯
* 消息构造 Hb5站长资讯
*/ Hb5站长资讯
function CLASS_MSN_MESSAGE(id,width,height,caption,title,message,target,action){ Hb5站长资讯
this.id = id; Hb5站长资讯
this.title = title; Hb5站长资讯
this.caption= caption; Hb5站长资讯
this.message= message; Hb5站长资讯
this.target = target; Hb5站长资讯
this.action = action; Hb5站长资讯
this.width = width?width:200; Hb5站长资讯
this.height = height?height:120; Hb5站长资讯
this.timeout= 150; Hb5站长资讯
this.speed = 20; Hb5站长资讯
this.step = 1; Hb5站长资讯
this.right = screen.width -1; Hb5站长资讯
this.bottom = screen.height; Hb5站长资讯
this.left = this.right - this.width; Hb5站长资讯
this.top = this.bottom - this.height; Hb5站长资讯
this.timer = 0; Hb5站长资讯
this.pause = false;Hb5站长资讯
this.close = false;Hb5站长资讯
this.autoHide = true;Hb5站长资讯
} Hb5站长资讯
Hb5站长资讯
/**//* Hb5站长资讯
* 隐藏消息方法 Hb5站长资讯
*/ Hb5站长资讯
CLASS_MSN_MESSAGE.prototype.hide = function(){ Hb5站长资讯
if(this.onunload()){
var offset = this.height>this.bottom-this.top?this.height:this.bottom-this.top; Hb5站长资讯
var me = this;
if(this.timer>0){ Hb5站长资讯
window.clearInterval(me.timer); Hb5站长资讯
}
var fun = function(){ Hb5站长资讯
if(me.pause==false||me.close){Hb5站长资讯
var x = me.left; Hb5站长资讯
var y = 0; Hb5站长资讯
var width = me.width; Hb5站长资讯
var height = 0; Hb5站长资讯
if(me.offset>0){ Hb5站长资讯
height = me.offset; Hb5站长资讯
} Hb5站长资讯
Hb5站长资讯
y = me.bottom - height; Hb5站长资讯
Hb5站长资讯
if(y>=me.bottom){ Hb5站长资讯
window.clearInterval(me.timer); Hb5站长资讯
me.Pop.hide(); Hb5站长资讯
} else { Hb5站长资讯
me.offset = me.offset - me.step; Hb5站长资讯
} Hb5站长资讯
me.Pop.show(x,y,width,height); Hb5站长资讯
} Hb5站长资讯
}
this.timer = window.setInterval(fun,this.speed) Hb5站长资讯
} Hb5站长资讯
} Hb5站长资讯
Hb5站长资讯
/**//* Hb5站长资讯
* 消息卸载事件,可以重写 Hb5站长资讯
*/ Hb5站长资讯
CLASS_MSN_MESSAGE.prototype.onunload = function() { Hb5站长资讯
return true; Hb5站长资讯
} Hb5站长资讯
/**//* Hb5站长资讯
* 消息命令事件,要实现自己的连接,请重写它 Hb5站长资讯
* Hb5站长资讯
*/ Hb5站长资讯
CLASS_MSN_MESSAGE.prototype.oncommand = function(){ Hb5站长资讯
//this.close = true;Hb5站长资讯
this.hide(); Hb5站长资讯
window.open("http://www.chinahtml.com");Hb5站长资讯
Hb5站长资讯
} Hb5站长资讯
/**//* Hb5站长资讯
* 消息显示方法 Hb5站长资讯
*/ Hb5站长资讯
CLASS_MSN_MESSAGE.prototype.show = function(){
var oPopup = window.createPopup(); //IE5.5+ Hb5站长资讯
Hb5站长资讯
this.Pop = oPopup; Hb5站长资讯
Hb5站长资讯
var w = this.width; Hb5站长资讯
var h = this.height; Hb5站长资讯
Hb5站长资讯
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站长资讯
str += "<TABLE style='BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#cfdef4 border=0>" Hb5站长资讯
str += "<TR>" Hb5站长资讯
str += "<TD style='FONT-SIZE: 12px;COLOR: #0f2c8c' width=30 height=24></TD>" Hb5站长资讯
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站长资讯
str += "<TD style='PADDING-RIGHT: 2px; PADDING-TOP: 2px' vAlign=center align=right width=19>" Hb5站长资讯
str += "<SPAN title=关闭 style='FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px' id='btSysClose' >×</SPAN></TD>" Hb5站长资讯
str += "</TR>" Hb5站长资讯
str += "<TR>" Hb5站长资讯
str += "<TD style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px' colSpan=3 height=" + (h-28) + ">" Hb5站长资讯
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站长资讯
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站长资讯
str += "</DIV>" Hb5站长资讯
str += "</TD>" Hb5站长资讯
str += "</TR>" Hb5站长资讯
str += "</TABLE>" Hb5站长资讯
str += "</DIV>" Hb5站长资讯
Hb5站长资讯
oPopup.document.body.innerHTML = str; Hb5站长资讯
Hb5站长资讯
Hb5站长资讯
this.offset = 0; Hb5站长资讯
var me = this;
oPopup.document.body.onmouseover = function(){me.pause=true;}Hb5站长资讯
oPopup.document.body.onmouseout = function(){me.pause=false;}
var fun = function(){ Hb5站长资讯
var x = me.left; Hb5站长资讯
var y = 0; Hb5站长资讯
var width = me.width; Hb5站长资讯
var height = me.height;
if(me.offset>me.height){ Hb5站长资讯
height = me.height; Hb5站长资讯
} else { Hb5站长资讯
height = me.offset; Hb5站长资讯
}
y = me.bottom - me.offset; Hb5站长资讯
if(y<=me.top){ Hb5站长资讯
me.timeout--; Hb5站长资讯
if(me.timeout==0){ Hb5站长资讯
window.clearInterval(me.timer); Hb5站长资讯
if(me.autoHide){Hb5站长资讯
me.hide(); Hb5站长资讯
}Hb5站长资讯
} Hb5站长资讯
} else { Hb5站长资讯
me.offset = me.offset + me.step; Hb5站长资讯
} Hb5站长资讯
me.Pop.show(x,y,width,height);
} Hb5站长资讯
Hb5站长资讯
this.timer = window.setInterval(fun,this.speed) Hb5站长资讯
Hb5站长资讯
Hb5站长资讯
Hb5站长资讯
var btClose = oPopup.document.getElementById("btSysClose"); Hb5站长资讯
Hb5站长资讯
btClose.onclick = function(){ Hb5站长资讯
me.close = true;Hb5站长资讯
me.hide(); Hb5站长资讯
} Hb5站长资讯
Hb5站长资讯
var btCommand = oPopup.document.getElementById("btCommand"); Hb5站长资讯
btCommand.onclick = function(){ Hb5站长资讯
me.oncommand(); Hb5站长资讯
} Hb5站长资讯
var ommand = oPopup.document.getElementById("ommand"); Hb5站长资讯
ommand.onclick = function(){ Hb5站长资讯
//this.close = true;Hb5站长资讯
me.hide(); Hb5站长资讯
window.open(ommand.href);Hb5站长资讯
} Hb5站长资讯
} Hb5站长资讯
/**//* Hb5站长资讯
** 设置速度方法 Hb5站长资讯
**/ Hb5站长资讯
CLASS_MSN_MESSAGE.prototype.speed = function(s){ Hb5站长资讯
var t = 20; Hb5站长资讯
try { Hb5站长资讯
t = praseInt(s); Hb5站长资讯
} catch(e){} Hb5站长资讯
this.speed = t; Hb5站长资讯
} Hb5站长资讯
/**//* Hb5站长资讯
** 设置步长方法 Hb5站长资讯
**/ Hb5站长资讯
CLASS_MSN_MESSAGE.prototype.step = function(s){ Hb5站长资讯
var t = 1; Hb5站长资讯
try { Hb5站长资讯
t = praseInt(s); Hb5站长资讯
} catch(e){} Hb5站长资讯
this.step = t; Hb5站长资讯
} Hb5站长资讯
Hb5站长资讯
CLASS_MSN_MESSAGE.prototype.rect = function(left,right,top,bottom){ Hb5站长资讯
try { Hb5站长资讯
this.left = left !=null?left:this.right-this.width; Hb5站长资讯
this.right = right !=null?right:this.left +this.width; Hb5站长资讯
this.bottom = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height; Hb5站长资讯
this.top = top !=null?top:this.bottom - this.height; Hb5站长资讯
} catch(e){} Hb5站长资讯
} Hb5站长资讯
var MSG1 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有1封消息","懒人图库"); Hb5站长资讯
MSG1.rect(null,null,null,screen.height-50); Hb5站长资讯
MSG1.speed = 10; Hb5站长资讯
MSG1.step = 5; Hb5站长资讯
//alert(MSG1.top); Hb5站长资讯
MSG1.show();
//同时两个有闪烁,只能用层代替了,不过层不跨框架 Hb5站长资讯
//var MSG2 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有2封消息","好的啊"); Hb5站长资讯
// MSG2.rect(100,null,null,screen.height); Hb5站长资讯
// MSG2.show(); Hb5站长资讯
//--> Hb5站长资讯
</SCRIPT> Hb5站长资讯



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