`
jsntghf
  • 浏览: 2482315 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

弹出浮动层

阅读更多
<html>
  <head>
    <style type="text/css">
      #tranDiv {
        position:absolute;
        left:0px;
        top:0px;
      }
      #tranDivBack {
        position:absolute;
        left:0px;
        top:0px;
        width:100%;
        height:100%;
        background-color:#000000;
        filter:alpha(Opacity=30);
        -moz-opacity:0.3;
        opacity:0.3;
      }
      #infoDiv {
        position:absolute;
        left:0px;
        top:0px;
        width:100%;
        height:100%;
        text-align:center;
      }
      .pop_box {
        background:#FFF;
        padding:20px;
        border:#666 8px solid;
      }
    </style>
    <script language="javascript"> 
      //弹出对话框,并使背景元素不可用
      //var div_width = 464;
      //var div_height = 445;
      function showWindow(width,height){ 
        location.href="#";
        //width = div_width;
        //height = div_height;
        var windowstr= document.getElementById("popLayer").innerHTML;
        document.getElementById("infoDiv").innerHTML=windowstr; 
        document.getElementById("infoDiv").style.left=((document.body.clientWidth-width)>0?(document.body.clientWidth-width):0)/2+"px"; 
        document.getElementById("infoDiv").style.top=100+"px"; 
        document.getElementById("infoDiv").style.zIndex=10001;
        document.getElementById("infoDiv").style.width=width; 
        document.getElementById("infoDiv").style.height=height; 
        document.getElementById("tranDiv").style.height=document.body.clientHeight+ "px"; 
        document.getElementById("tranDiv").style.width=document.body.clientWidth+ "px"; 
        document.getElementById("tranDiv").style.display=""; 
        document.getElementById("tranDivBack").style.display=""; 
        document.getElementById("tranDivBack").style.zIndex=10000;
        document.getElementById("infoDiv").style.display=""; 
      } 
      function closeWindow(){
        document.getElementById("tranDiv").style.display="none"; 
      } 
    </script>
  </head>
  <!--层遮罩部分-->
  <div id="tranDiv" style="display:none;">
    <div id="tranDivBack"></div>
    <div id="infoDiv"></div>
  </div>
  <!--层遮罩部分结束-->
  <!--弹出层-->
  <div id="popLayer" style="display:none;">
    <div class="pop_box">
      <img src="test.jpg" width="424" height="405" />
      <button onClick="closeWindow();">关闭</button>
    </div>
  </div>
  <a href="javascript:showWindow(800,600);">点击此处看看</a>
</html>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics