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