Html代码和JavaScript代码来模仿一下QQ、MSN、淘宝旺旺、等等的聊天软件这一功能。
先给大家贴出来的是Html代码:
以下是popmsg.js代码:
function CLASS_MSN_MESSAGE(width,height,caption,title,message,href,id){
this.title = title;
this.caption= caption;
this.message= message;
this.href= href;
this.id= id;
this.width = width?width:200;
this.height = height?height:120;
this.timeout= 150;
this.speed = 20;
this.step = 1;
this.right = screen.width -1;
this.bottom = screen.height;
this.left = this.right - this.width;
this.top = this.bottom - this.height;
this.timer = 0;
this.pause = false;
this.close = false;
this.autoHide = true;
}
CLASS_MSN_MESSAGE.prototype.hide = function(){
if(this.onunload()){
var ffset = this.height>this.bottom-this.top?this.height:this.bottom-this.top;
var me = this;
if(this.timer>0){
window.clearInterval(me.timer);
}
var fun = function(){
if(me.pause==false||me.close){
var x = me.left;
var y = 0;
var width = me.width;
var height = 0;
if(me.offset>0){
height = me.offset;
}
y = me.bottom - height;
if(y>=me.bottom){
window.clearInterval(me.timer);
me.Pop.hide();
} else {
me.offset = me.offset - me.step;
}
me.Pop.show(x,y,width,height);
}
}
this.timer = window.setInterval(fun,this.speed)
}
}
CLASS_MSN_MESSAGE.prototype.onunload = function() {
return true;
}
CLASS_MSN_MESSAGE.prototype.oncommand = function(){
this.hide();
}
CLASS_MSN_MESSAGE.prototype.show = function(){
var Popup = window.createPopup(); //IE5.5+
this.Pop = oPopup;
var w = this.width;
var h = this.height;
var str = "
| " | " + this.caption + " | "" str += "× | "
| " str += "" str += " | " ||
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22434610/viewspace-614900/ ,如需转载,请注明出处,否则将追究法律责任。