标签:style blog http color java strong io art
1 function SetWinHeight(obj) 2 { 3 var win=obj; 4 if (document.getElementById) 5 { 6 if (win && !window.opera) 7 { 8 if (win.contentDocument && win.contentDocument.body.offsetHeight) 9 win.height = win.contentDocument.body.offsetHeight; 10 else if(win.Document && win.Document.body.scrollHeight) 11 win.height = win.Document.body.scrollHeight; 12 } 13 } 14 }
<iframe width="778" align="center" height="200" id="win" name="win" onload="Javascript:SetWinHeight(this)" frameborder="0" scrolling="no" src="1.htm"></iframe>
2.经典代码 iFrame 自适应高度,在IE6/IE7/IE8/Firefox/Opera/Chrome/Safari通过测试。
HTML代码:
<iframe src="http://www.fufuok.com/" id="iframepage" name="iframepage" frameBorder=0 scrolling=no width="100%" onLoad="iFrameHeight()" ></iframe>Javascript代码:
<script type="text/javascript" language="javascript">
function iFrameHeight() {
var ifm= document.getElementById("iframepage");
var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;
if(ifm != null && subWeb != null) {
ifm.height = subWeb.body.scrollHeight;
}
}
</script>
http://www.jb51.net/article/15780.htm
Iframe 自适应高度的方法!,布布扣,bubuko.com
标签:style blog http color java strong io art
原文地址:http://www.cnblogs.com/mlloc-clove/p/3880911.html