日期:2014-05-16  浏览次数:20347 次

很好用的JS遮盖层,Jquery,javascript遮盖层


<input type="button" name="ss" value="cc" onclick="openNewDiv()" />


<SCRIPT language="javascript" type="text/javascript">

var docEle = function()
{
    return document.getElementById(arguments[0]) || false;
}
function openNewDiv()
{
    var m = "mask";
    if (docEle(m)) document.body.removeChild(docEle(m));
  
    //mask遮罩层

    var newMask = document.createElement("div");
    newMask.id = m;
    newMask.style.position = "absolute";
    newMask.style.zIndex = "1";
    _scrollWidth = Math.max(document.body.scrollWidth,document.documentElement.scrollWidth);
    _scrollHeight = Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
    newMask.style.width = (_scrollWidth-20) + "px";
    newMask.style.height = (_scrollHeight-20) + "px";
    newMask.style.top = "0px";
    newMask.style.left = "0px";
    newMask.style.background = "#e8e8e8";
    newMask.style.filter = "alpha(opacity=40)";
    newMask.style.opacity = "0.40";
    newMask.innerHTML ="<div  align='center' style='margin-top: 80px;'><img src='..//loading.gif' width='16' height='16'  style='CURSOR: pointer'><br/><br/><font color='#ff0000'><b>请等待.......</b></font><div>";
    document.body.appendChild(newMask);
}
</SCRIPT>