js 弹出DIV层和关闭DIV层

js 弹出DIV层
function Pop_Msg(id) {

    var msgw, msgh, bordercolor;
    var str = document.getElementById(id);
    str.style.display = "block";
    var sWidth, sHeight;
    var w = str.offsetWidth;
    var h = str.offsetHeight;
    sWidth = document.body.offsetWidth;
    sHeight = document.body.offsetHeight + 5;
    var bgObj = document.createElement("div");
    bgObj.setAttribute('id', 'bgDiv');
    bgObj.style.position = "absolute";
    bgObj.style.top = "0";
    bgObj.style.background = "#000";
    bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=4,opacity=55,finishOpacity=35";
    bgObj.style.opacity = "0.8";
    bgObj.style.left = "0";
    bgObj.style.width = "100%";
    bgObj.style.height = sHeight + "px";
    document.body.appendChild(bgObj);

    var sWidth, sHeight;
    sWidth = document.body.offsetWidth;
    sHeight = document.body.offsetHeight;
    var msgObj = document.createElement("div")
    msgObj.setAttribute("id", "msgDiv");
    msgObj.setAttribute("align", "center");
    msgObj.style.position = "absolute";
    msgObj.style.zIndex = 10001;

    msgObj.style.font = "12px/1.6em 宋体, Geneva, Arial, Helvetica, sans-serif";
    msgObj.style.border = "0px solid #C1D7EC";
    msgObj.style.width = w;
    msgObj.style.height = h;
    msgObj.style.top = (document.documentElement.scrollTop + 20) + "px";
    msgObj.style.left = (sWidth - w) / 2 + "px";
    document.body.appendChild(msgObj);
    document.getElementById("msgDiv").appendChild(str);
}

 

JS 关闭弹出的DIV层
function Close_Msg(id, flg) {
    iframeArry.pop();
    var str = document.getElementById(id);
    str.style.display = "none";
    document.body.appendChild(str);
    document.body.removeChild(document.getElementById("bgDiv"));
    document.body.removeChild(document.getElementById("msgDiv"));
    if (flg != undefined & flg == "1") {
        document.location.href = document.location.href;
    }
}
posted @ 2012-07-06 10:55  wongley  阅读(770)  评论(0编辑  收藏  举报