像很多网站那样
弹出一个确认层!可以移动!
层下面的背景变灰色,都变为不可用!只有关闭该层,才恢复原状!怎么实现?
用的是JS?

解决方案 »

  1.   

    <script language="javascript">
     var docEle = function(a) {
      return document.getElementById(a) || false;
     }
     function openNewDiv(_id) {
      var m = "mask";
      if (docEle(_id)) document.removeChild(docEle(_id));
      if (docEle(m)) document.removeChild(docEle(m));
      // 新激活图层
      var newDiv = document.createElement("div");
      newDiv.id = _id;
      newDiv.style.position = "absolute";
      newDiv.style.zIndex = "9999";
      newDiv.style.width = "500px";
      newDiv.style.height = "300px";
      newDiv.style.top = "50px";
      //newDiv.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中
      newDiv.style.background = "#EFEFEF";
      newDiv.style.border = "1px solid #860001";
      newDiv.style.padding = "5px";
      newDiv.innerHTML = "新激活图层内容&nbsp;&nbsp;&nbsp;&nbsp;";
      document.body.appendChild(newDiv);
      // mask图层
      var newMask = document.createElement("div");
      newMask.id = m;
      newMask.style.position = "absolute";
      newMask.style.zIndex = "1";
      newMask.style.width = document.body.scrollWidth + "px";
      newMask.style.height = document.body.scrollHeight + "px";
      newMask.style.top = "0px";
      newMask.style.left = "0px";
      //newMask.style.background = "#000";
      newMask.style.filter = "alpha(opacity=40)";
      newMask.style.opacity = "0.40";
      document.body.appendChild(newMask);  // 关闭mask和新图层
      var newA = document.createElement("a");
      newA.href = "#";
      newA.innerHTML = "关闭";
      newA.onclick = function() {
       document.body.removeChild(docEle(_id));
       document.body.removeChild(docEle(m));
       return false;
      }
      newDiv.appendChild(newA);
     }
    </script>
    <p><a href="#" onclick="openNewDiv('newDiv');return false;">激活新层</a>
    <p>11111111111111111111111
    <p>11111111111111111111111
    <p>11111111111111111111111
    <p>11111111111111111111111
      

  2.   

    楼上的提复杂了,看了都心烦。<div id="msgDiv" align="center" style="background-color:white; border:1px solid #336699;display:none; position:absolute; left:50%; top:50%; font:12px/1.6em Verdana,Geneva,Arial,Helvetica,sans-serif; margin-left:-225px; margin-top:npx; width:400px; height:100px; text-align:center; line-height:25px; z-index:100001;">LZ自己看吧,当操作的时候就把层DIV的z-index:100001 放在最顶,并且设置 display  不为NONE即可!!
      

  3.   

    告诉楼主一个最简单的
    创建个iframe层,背景设置成灰色就ok了我都这样搞的
      

  4.   

    <div id="msgDiv" align="center" style="background-color:white; border:1px solid #336699;display:none; position:absolute; left:50%; top:50%; font:12px/1.6em Verdana,Geneva,Arial,Helvetica,sans-serif; margin-left:-225px; margin-top:npx; width:400px; height:100px; text-align:center; line-height:25px; z-index:100001;">测试</div><input type="submit" name="button" id="button" value="提交" onClick="a()">点出层的时候,按钮怎么还可以用啊?