`

JS 遮罩层

    博客分类:
  • JS
阅读更多

不太明白,留着有用。

zindex决定了各个层的先后顺序,这个很重要。

var zindex=100;
function zhegai(){ 
  var ss=document.getElementById("zhegai");
  if(isempty(ss))
	var backDiv =document.createElement('div');
  else
	  return false;
  var bWidth=parseInt(document.body.scrollWidth);

  var bHeight=document.body.scrollHeight;
  if(document.body.offsetHeight>bHeight)bHeight=document.body.offsetHeight;
  
  $(backDiv).attr("id","zhegai");
  $(backDiv).attr("class","zhegai");
  backDiv.style.cssText='top:0px;left:0px;position:absolute;filter:Alpha(Opacity=50);width:'+bWidth+'px;height:'+bHeight+'px;z-index:'+ zindex +';';
  backDiv.style.background="#777";
  zindex++;
  backDiv.innerHTML = '<iframe style=\'width:100%;height:100%;filter:Alpha(Opacity=10);position:absolute;z-index:'+ zindex +';border:none\' frameborder=\'no\' border=\'0\' ></iframe>';
  zindex++;
  var msgw,msgh,bordercolor;
      msgw=300;//
      msgh=100;//
      bordercolor="#335EA8";//  
  var msgObj=document.createElement("div")
   msgObj.setAttribute("id","msgDiv");
   msgObj.setAttribute("align","center");
//   msgObj.style.background="white";
//   msgObj.style.border="1px solid " + bordercolor;
   msgObj.style.position = "absolute";
   msgObj.style.left = "50%";
   msgObj.style.top = "30%";
   msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
   //msgObj.style.marginLeft = "-100px" ;        //
   msgObj.style.marginLeft =-(window.screen.width/2-msgw)+"px";
   $("#msgDiv").fadeTo(2000,0.5,function(){alert("设置透明度");});
   //msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
   msgObj.style.width = msgw + "px";
   msgObj.style.height =msgh + "px";
   msgObj.style.textAlign = "center";
   msgObj.style.lineHeight ="25px";
   msgObj.style.zIndex = "9999999";
   document.body.appendChild(msgObj);
//  $("#"+query_div_id).css("z-index",zindex);
  document.body.appendChild(backDiv);
  $(msgObj).append("<img src=\"eea/images/0504315.gif\"/><br/>执行中请稍后......");
  $(backDiv).show();
  $(backDiv).focus();
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics