Iframe 自适应高度的方法!
2014-07-31 15:21
363 查看
第一种方法:代码简单,兼容性还可以,大家可以先测试下。
function SetWinHeight(obj) { var win=obj; if (document.getElementById) { if (win && !window.opera) { if (win.contentDocument && win.contentDocument.body.offsetHeight) win.height = win.contentDocument.body.offsetHeight; else if(win.Document && win.Document.body.scrollHeight) win.height = win.Document.body.scrollHeight; } } }
<iframe width="778" align="center" height="200" id="win" name="win" onload="Javascript:SetWinHeight(this)" frameborder="0" scrolling="no" src="1.htm"></iframe> 2.[b]经典代码 iFrame 自适应高度,在IE6/IE7/IE8/Firefox/Opera/Chrome/Safari通过测试。 HTML代码:[/b] <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> /article/1272354.html
相关文章推荐
- iframe自适应高度的多种方法方法小结
- 多层嵌套iframe 自适应高度的解决方法
- iframe自适应高度的多种方法方法小结
- iframe自适应高度的多种方法方法小结
- iframe页面调用高度自适应方法代码,兼容IE,FF
- iframe 自适应高度问题解决方法
- iframe自适应高度的多种方法方法小结(转)
- iframe自适应高度的方法
- iframe自适应高度的多种方法方法小结
- iframe自适应高度的多种方法方法小结
- iframe自适应高度的方法
- iframe自适应高度的多种方法方法小结
- iframe自适应高度的多种方法方法小结
- iframe自适应高度的多种方法方法小结
- iframe跨域自适应高度问题的解决方法
- iframe自适应高度的多种方法方法小结
- iframe自适应高度,多层嵌套iframe自适应高度的解决方法
- iframe自适应高度的多种方法方法小结
- iframe自适应高度的多种方法方法小结
- IFRAME自适应高度的解决方法