HelloWorld 善战者,求之于势,不责于人;故能择人而任势。

知止而后有定,定而后能静,静而后能安,安而后能虑,虑而后能得。物有本末,事有终始。知所先后,则近道矣。

  BlogJava :: 首页 ::  :: 联系 ::  :: 管理 ::
  167 随笔 :: 1 文章 :: 40 评论 :: 0 Trackbacks

/**
* 功能: 仿Msn信息提示
* @param height : 信息框的高度
* @param width : 信息框的宽度
* @param title : 信息框的标题
* @param innerHTML : 信息框面板显示内容,放在<DIV></DIV>中,任意的HTML代码
* @return void
*/
function CMsnMsg(width,height,title,innerHTML) {
this.height = (height!=null)?height:150;
this.width = (width!=null)?width:200;
this.title = title;
this.innerHTML = innerHTML;
//以下为默认值设置,可以调用对象的成员直接修改
//信息框默认为自动隐藏
this.autoHide = true;
//信息框右边的x坐标
this.right = screen.width - 2;
//信息框的左部x坐标
this.left = this.right - this.width;
//信息框的底部y坐标
this.bottom = screen.height;
//信息框的顶部的y坐标
this.top = this.bottom - this.height;
//默认为没有关闭
this.close = false;
//默认为没有停止不动
this.pause = false;
//信息框移动速度
this.speed = 15;
//正常显示需要多久的时间,然后关闭掉
this.timeout = 300;
//设置步长
this.step = 1;
//定时器
this.timer = 0;
}

/**
* CMsnMsg对象的显示方法
*/
CMsnMsg.prototype.show = function() {
var pop = window.createPopup();
this.pop = pop;
      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: "
      str +=this.width + "px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: " + this.height + "px; BACKGROUND-COLOR: #c9d3f3'>"  
      str += "<TABLE style='BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#cfdef4 border=0>"  
      str += "<TR>"  
      str += "<TD style='FONT-SIZE: 12px;COLOR: #0f2c8c' width=30 height=24></TD>"  
      str += "<TD style='PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #1f336b; PADDING-TOP: 4px' vAlign=center width='100%'>" + this.title + "</TD>"  
      str += "<TD style='PADDING-RIGHT: 2px; PADDING-TOP: 2px' vAlign=center align=right width=19>"  
      str += "<SPAN title=关闭 style='FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: black; MARGIN-RIGHT: 4px' id='btSysClose' >×</SPAN></TD>"  
      str += "</TR>"  
      str += "<TR>"  
      str += "<TD style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px' colSpan=3 height=" + (this.height-28) + ">"  
      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;";
      str += "BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 8px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%'>"  
str += this.innerHTML;
      str += "</DIV>"  
      str += "</TD>"  
      str += "</TR>"  
      str += "</TABLE>"  
      str += "</DIV>"  
      pop.document.body.innerHTML = str;
      this.offset = 0;
      var me = this;
      pop.document.body.onmouseover = function() {me.pause = true;};
      pop.document.body.onmouseout = function() {me.pause = false;};
    
      var fun = function() {
       var x = me.left;
       var y = 0;
       var width = me.width;
       var height = me.height;
       if (me.offset > me.height) {
        height = me.height;
       } else {
        height = me.offset;
       }
       y = me.bottom - me.offset;
    if (y <= me.top) {
     me.timeout -= 1;
     if (me.timeout == 0) {
      window.clearInterval(me.timer);
      if (me.autoHide) {
       me.hide();
      }
     }
    } else {
     me.offset += me.step;
    }
    me.pop.show(x,y,width,height);
      }    
      this.timer = window.setInterval(fun,this.speed);
      var btClose = pop.document.getElementById("btSysClose");
      btClose.onclick = function(){  
          me.close = true;
          me.hide();
      }
}
/**
* CMsnMsg对象的关闭方法
*/
CMsnMsg.prototype.hide = function() {
flag = true;
var offset = 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 || 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.step;
        }
        me.pop.show(x,y,width,height);
       }     
      }
      this.timer = window.setInterval(fun,this.speed);
}
var msg = null;
function test() {
if (msg == null || !msg.pause) {
     msg = new CMsnMsg(300,220,"ABM系统提示");
     msg.innerHTML = "<A href='www.baidu.com'>www.baidu.com</a>"
     msg.show();
}
}
window.setInterval("test();",20000);



</script>

posted on 2007-08-13 18:42 helloworld2008 阅读(353) 评论(0)  编辑  收藏 所属分类: html/javascript/css

只有注册用户登录后才能发表评论。


网站导航: