右下角滑出窗口

 
  1. /* 
  2.  *Author:sohighthesky 
  3.  *From:http://www.uedsky.com/ 
  4.  *Date:2009-11-9 
  5.  */  
  6. /* 
  7.  *box 指定要显示消息框或者其id 
  8.  *options:参见代码中setOptions中的注释 
  9.  */  
  10. var sheyMsg=function(box,options) {  
  11.     this.box=this.g(box);  
  12.     this.setOptions(options);  
  13.     this.init();  
  14. }  
  15. sheyMsg.prototype={  
  16.     ae:function(e,call) {  
  17.         if(window.addEventListener)window.addEventListener(e,call,false);  
  18.         else window.attachEvent("on"+e,call);  
  19.     },  
  20.     g:function(id) {return typeof(id)=="string"?document.getElementById(id):id; },  
  21.     isFixed:!window.ActiveXObject || (navigator.userAgent.indexOf("MSIE 6")==-1 &&  document.compatMode=="CSS1Compat"),  
  22.     setOptions:function(options) {  
  23.         this.options={//默认配置   
  24.                 showDelay:10,//显示延时   
  25.                 autoHide:30,//自动隐藏时间,设置为0时,不自动隐藏   
  26.                 onShow:function(){},//显示后调用   
  27.                 onHide:function(){}//隐藏后调用   
  28.         };  
  29.         for(var o in options) {  
  30.             this.options[o]=options[o];  
  31.         }  
  32.     },  
  33.     hide:function() {//隐藏   
  34.         var _top=this.box.clientHeight;  
  35.         var o=this;  
  36.         if(/ing$/.test(o.status))return;  
  37.         o.status="hiding";  
  38.         clearTimeout(o.tt);  
  39.         o.t=setInterval(function() {  
  40.             if(o.isFixed)  
  41.                 o.box.style.bottom=(-o.box.clientHeight+(--_top))+'px';  
  42.             else  
  43.                 o.box.style.top=o.de.scrollTop+o.de.clientHeight-5-(--_top) +"px";  
  44.             if(_top==-5) {  
  45.                 clearInterval(o.t);  
  46.                 o.status="hide";  
  47.                 o.box.style.display="none";  
  48.                 o.options.onHide();  
  49.             }  
  50.         },5);  
  51.     },  
  52.     show:function() {//显示   
  53.         var _top=0;  
  54.         var o=this;  
  55.         if(/ing$/.test(o.status))return;  
  56.         o.status="showing";  
  57.         clearTimeout(o.tt);  
  58.         o.box.style.display="block";  
  59.         o.t=setInterval(function() {  
  60.             if(o.isFixed)  
  61.                 o.box.style.bottom=(-o.box.clientHeight+(++_top))+"px";  
  62.             else  
  63.                 o.box.style.top=(o.de.scrollTop+o.de.clientHeight-5-(++_top)) +"px";  
  64.             if(_top==o.box.clientHeight) {  
  65.                 clearInterval(o.t);  
  66.                 o.status="show";  
  67.                 o.options.onShow();  
  68.                 var h=o.options.autoHide-0;  
  69.                 if(h) o.tt=setTimeout(function() {o.hide();},h*1000);  
  70.             }  
  71.         },1);  
  72.     },  
  73.     fixIE6:function() {//IE6 滚动定位   
  74.         this.box.style.left=this.de.scrollLeft+this.de.clientWidth-this.box.clientWidth-2+"px";  
  75.         if(this.status=="show") {              
  76.             this.box.style.top=this.de.scrollTop+this.de.clientHeight-this.box.clientHeight-5+"px";  
  77.         } else if(this.status=="hide") {  
  78.             this.box.style.top=this.de.scrollTop+this.de.clientHeight+5+"px";  
  79.         }  
  80.     },  
  81.     init:function() {  
  82.         with(this.box.style) {  
  83.             display="block";//显示之后才能取出宽度和高度   
  84.             if(this.isFixed) {  
  85.                 position="fixed";  
  86.                 right="2px";  
  87.                 bottom=(-this.box.clientHeight-5)+"px";  
  88.             } else {  
  89.                 position="absolute";  
  90.             }  
  91.         }  
  92.         this.status="hide";  
  93.         var o=this;  
  94.         if(!this.isFixed) {  
  95.             o.de=document.compatMode=="CSS1Compat"?document.documentElement:document.body;  
  96.             var timer;  
  97.             this.ae("resize",function() { clearTimeout(timer);timer=setTimeout(function(){o.fixIE6.call(o)},30);});  
  98.             this.ae("scroll",function() { clearTimeout(timer);timer=setTimeout(function(){o.fixIE6.call(o)},30);});  
  99.             this.fixIE6();//加载时指定位置   
  100.         }  
  101.         o.box.style.display="none";  
  102.         o.tt=setTimeout(function() {o.show();},o.options.showDelay*1000);  
  103.     }  
  104. }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值