javascript 浮动窗口滚动.拖动

<script type="text/javascript">
 function close(){
  QQkefu.style.display="none";
  return true;
 }
  function msgBox()
 {
  this.container = "aaaa";
  this.titleheadArea = "titlehead";
  this.width = 154;
  this.height = 105;
  this.smallHeight = 20;
  this.smallId = "small";
  this.area = ( document.compatMode.toLowerCase()=="css1compat" ) ? document.documentElement : document.body;
  this.space = 5;
  this.timer;
  this.timeOut = 150;
  this.smalled = false;
  window.msgBoxListener = this;
  this.$(this.smallId).οnclick= function(){msgBoxListener.toSmall()};
 }
 msgBox.prototype.flow = function()
 {
  this.$(this.container).style.position = "absolute";
  this.$(this.container).style.zIndex = "1000";
  if(this.smalled)
  {
   this.$(this.container).style.top = this.area.scrollTop + this.area.clientHeight - this.smallHeight - this.space + "px";
  }else{
   this.$(this.container).style.top = this.area.scrollTop + this.area.clientHeight - this.height - this.space + "px";
  }
   this.$(this.container).style.left = this.area.scrollLeft + this.area.clientWidth - this.width - this.space + "px";
  }
  msgBox.prototype.toSmall = function()
  {
   if(this.smalled)
   {
    this.$(this.container).style.marginTop = -this.height + "px";
    this.$(this.container).style.height = this.height + "px";
     this.smalled = false;
    this.flow();
    this.$(this.container).style.marginTop = "0px";
   }else{
    this.$(this.container).style.height = this.smallHeight + "px";
     this.smalled = true;
    this.flow();
   }
  } 
  msgBox.prototype.auto = function()
  {
   this.flow();
   window["onresize"]=function(){msgBoxListener.flow();};
   window["onscroll"]=function(){msgBoxListener.flow();};
   document.onmousedown = function(){clearInterval(msgBoxListener.timer);msgBoxListener.titlehead(msgBoxListener.container, msgBoxListener.titleheadArea);};
  }
  msgBox.prototype.titlehead = function(container, titlehead)
  {
   var IMOUSEDOWN = true;
   var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
   container = document.getElementById(container);
   titlehead = document.getElementById(titlehead);
   if(titlehead)
   {
    try{
     if(IMOUSEDOWN){
      titlehead.οnmοusedοwn=function(a){
      var d=document;
      if(!a)a=window.event;
      titlehead.style.cursor="move";
      var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
      if(titlehead.setCapture)
       titlehead.setCapture();
      else if(window.captureEvents)
       window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
      d.οnmοusemοve=function(a){
       if(!a)a=window.event;
       if(!a.pageX)a.pageX = (a.clientX<0 ?0:a.clientX);
       if(!a.pageY)a.pageY = (a.clientY <0 ?0:a.clientY);
        var tx = a.pageX-x, ty = a.pageY-y;
        if(isIE){
         ty = ty + document.documentElement.scrollTop - document.documentElement.clientTop;
        }
       container.style.position = "absolute";
       container.style.left = tx+"px";
       container.style.top = ty+"px";
      };
      d.οnmοuseup=function(){
       if(titlehead.releaseCapture)
        titlehead.releaseCapture();
       else if(window.captureEvents)
        window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
       d.οnmοusemοve=null;
       d.οnmοuseup=null;
      };
     };
     }else{
      container.style.cursor="pointer";
      titlehead.style.cursor="move";
     }
    }catch(e){
     alert(e);
    }
   }
  }
  msgBox.prototype.$ = function(ele)
  {
   return document.getElementById(ele);
  }
  var msgBox1 = new msgBox();
  msgBox1.auto();
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值