从站长之家找了一些关于遮罩层的代码特效,自己使用时,点击按钮却不显示遮罩层?请问是什么原因?
样式表:<style type="text/css">
  .hidden{display:none;}
   #www_zzjs_net{
        width:498px;
        height:100px;
        padding:4px 10px 10px;
        background-color:#FFFFFF;
        border:1px solid #05549d;
        color:#333333;
        line-height:24px;
        text-align:left;
        -webkit-box-shadow:5px 2px 6px #000;
        -moz-box-shadow:3px 3px 6px #555;
      }
</style>
JS脚本:<script type="text/javascript">
    //判断浏览器ie6创建的div样式和非ie6创建的div样式
    //创建div
    function showid_zzjs_net(idname) {
        var isIE = (document.all) ? true : false;
        var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
        var newbox = document.getElementById(idname);
        newbox.style.zIndex = "9999";
        newbox.style.display = "block"
        newbox.style.position = !isIE6 ? "fixed" : "absolute";
        newbox.style.top = newbox.style.left = "50%";
        newbox.style.marginTop = -newbox.offsetHeight / 2 + "px";
        newbox.style.marginLeft = -newbox.offsetWidth / 2 + "px";
        var layer = document.createElement("div");
        layer.id = "layer";
        layer.style.width = layer.style.height = "100%";
        layer.style.position = !isIE6 ? "fixed" : "absolute";
        layer.style.top = layer.style.left = 0;
        layer.style.backgroundColor = "#000";
        layer.style.zIndex = "9998";
        layer.style.opacity = "0.6";
        document.body.appendChild(layer);
        var sel = document.getElementsByTagName("select");
        for (var i = 0; i < sel.length; i++) {
            sel[i].style.visibility = "hidden";
        } 
        function layer_iestyle() {
            layer.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)
+ "px";
            layer.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) +
"px";
        } 
        function newbox_iestyle() {
            newbox.style.marginTop = document.documentElement.scrollTop - newbox.offsetHeight / 2 + "px";
            newbox.style.marginLeft = document.documentElement.scrollLeft - newbox.offsetWidth / 2 + "px";
        }
        if (isIE) { layer.style.filter = "alpha(opacity=60)"; }
        if (isIE6) {
            layer_iestyle()
            newbox_iestyle();
            window.attachEvent("onscroll", function () {
                newbox_iestyle();
            })
            window.attachEvent("onresize", layer_iestyle)
        } 
        layer.onclick = function () {
            newbox.style.display = "none"; layer.style.display = "none"; for (var i = 0; i < sel.length; i++) {
                sel[i].style.visibility = "visible";
            } 
        }
    } 
</script>
引用:<asp:Button ID="Button7" runat="server" Text="点击显示" OnClientClick='showid("www_zzjs_net");' /> 
    <div id ="www_zzjs_net" style =" display :none ;">点击灰色区域遮罩层消失</div>

解决方案 »

  1.   

    最新补充:<asp:Button ID="Button7" runat="server" Text="点击显示" OnClientClick='showid_zzjs_net("www_zzjs_net");' /> 现在的问题是这样的:遮罩层显示一瞬间后就自动消失。。
      

  2.   

    不知道为什么 改用input写的按钮显示事件,遮罩层就会显示,鼠标弹起后也不会消失。。现在问题已经自己解决了至于为什么。。倒还真不知晓了