弹出窗口的兼容实现方法

前端之家收集整理的这篇文章主要介绍了弹出窗口的兼容实现方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编来看看吧。
CSS代码如下:

  html,body {
    margin: 0;
    padding: 0;
  }
  body {
  }
  #div1 {
    height: 2000px;
  }
  #floatedLayer {
    position: fixed;
    _position: absolute;
  }

/***  来自编程之家 jb51.cc (jb51.cc)***/
HTML代码如下:

  <div id="floatedLayer">
    <iframe src="demo.html" width="580" height="542" frameborder="no"></iframe>
  </div>
  <div id="div1"></div>
  <script type="text/javascript">
    var floatedLayer = document.getElementById("floatedLayer");
    function adjustPopupWin() {
      var height = document.documentElement.clientHeight,        width = document.documentElement.clientWidth;       
      floatedLayer.style.left = Math.max((width - floatedLayer.offsetWidth) / 2,0) + "px";
      floatedLayer.style.top = Math.max((height - floatedLayer.offsetHeight) / 2,0) + "px";
    }
  </script>
  <!--[if IE 6]>
  <script type="text/javascript">
    function adjustPopupWin() {
      var height = document.documentElement.clientHeight,        width = document.documentElement.clientWidth;
      floatedLayer.style.left = Math.max((width - floatedLayer.offsetWidth) / 2,0) + document.documentElement.scrollLeft + "px";
      floatedLayer.style.top = Math.max((height - floatedLayer.offsetHeight) / 2,0) + document.documentElement.scrollTop + "px";
    }
    window.onscroll = adjustPopupWin;
  </script>
  <![endif]-->
  <script type="text/javascript">
    window.onresize = adjustPopupWin;
    adjustPopupWin();
  </script>
</body>
</html>
<!--   来自 编程之家 jb51.cc (jb51.cc)-->
原文链接:https://www.f2er.com/html/527544.html

猜你在找的HTML相关文章