js mask

function mask(config){

if(typeof config == 'object'){

this.win = config.win || window;

this.tip = config.tip || '请等待...';

this.id = config.id || 'mask';

this.tipColor = config.fontColor || '#ff0000';

}else{

this.win = window;

this.tip = '请等待...';

this.id = 'mask';

this.tipColor = '#ff0000';

}

this.doc = this.win.document;

this.show = function(){

var maskElement = this.doc.getElementById(this.id);

   if (maskElement) this.doc.body.removeChild(maskElement); 

   //mask遮罩层 

   var newMask = this.doc.createElement("div"); 

   newMask.id = this.id; 

   newMask.style.position = "absolute"; 

   newMask.style.zIndex = "1"; 

   var _scrollWidth = Math.max(this.doc.body.scrollWidth,this.doc.documentElement.scrollWidth); 

   var _scrollHeight = Math.max(this.doc.body.scrollHeight,this.doc.documentElement.scrollHeight); 

   newMask.style.width = (_scrollWidth-25) + "px"; 

   newMask.style.height = (_scrollHeight-25) + "px"; 

   newMask.style.top = "0px"; 

   newMask.style.left = "0px"; 

   newMask.style.background = "#E1E1E1"; 

   newMask.style.filter = "alpha(opacity=40)"; 

   newMask.style.opacity = "0.40"; 

   newMask.innerHTML ='<div  align="center" style="margin-top:' + _scrollHeight /2 + 'px;"><font color="' + this.tipColor + '"><b>' + this.tip + '</b></font><div>'; 

   this.doc.body.appendChild(newMask); 

};

this.remove = function(){

this.doc.body.removeChild(this.doc.getElementById(this.id));

};

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值