js实现简单的遮罩功能


    /*
     * 显示loading遮罩层
     */
    function loading() {
        var mask_bg = document.createElement("div");
        mask_bg.id = "mask_bg";
        mask_bg.style.position = "absolute";
        mask_bg.style.top = "0px";
        mask_bg.style.left = "0px";
        mask_bg.style.width = "100%";
        mask_bg.style.height = "100%";
        mask_bg.style.backgroundColor = "#777";
        mask_bg.style.opacity = 1;
        mask_bg.style.zIndex = 998;
        document.body.appendChild(mask_bg);

        var mask_msg = document.createElement("div");
        mask_msg.style.position = "absolute";
        mask_msg.style.top = "50%";
        mask_msg.style.marginTop = "-10px";
        mask_msg.style.left = "50%";
        mask_msg.style.marginLeft = "-20px";
        mask_msg.style.color = "white";
        mask_msg.style.textAlign = "center";
        mask_msg.style.fontSize = "14px";
        mask_msg.style.fontWeight = "bold";
        mask_msg.style.zIndex = 999;
        mask_msg.innerText = "页面加载中,请稍后...";
        mask_bg.appendChild(mask_msg);
    }

    /*
     * 关闭遮罩层
     */
    function loaded() {
        $("#main").show();
        contentFormOnload2();
        var mask_bg = document.getElementById("mask_bg");
        if (mask_bg != null)
            mask_bg.parentNode.removeChild(mask_bg);
    }

声明:Wayen|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - js实现简单的遮罩功能


-当你感到最无助困难的时候,那就是离成功最近的时候。-Martin Frohm