源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

iframe 自适应高度[在IE6 IE7 FF下测试通过]

  • 时间:2022-12-23 07:44 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:iframe 自适应高度[在IE6 IE7 FF下测试通过]
第一种方法:
[u]复制代码[/u] 代码如下:
<script type="text/javascript" language="javascript"> <!-- //调整 PageContent 的高度 function TuneHeight() { var frm = document.getElementById("content01"); var subWeb = document.frames ? document.frames["content01"].document : frm.contentDocument; if(frm != null && subWeb != null) { frm.height = subWeb.body.scrollHeight; } } //--> </script> <iframe id="content01" name="content01" frameBorder=0 scrolling=no src="main.html" width="100%"onLoad="TuneHeight()" ></iframe>
第二种方法: js code:
[u]复制代码[/u] 代码如下:
//iframe自适应高度[在IE6 IE7下测试通过] function reSetIframe(){ var iframe = document.getElementById("iframeId"); try{ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; var height = Math.max(bHeight, dHeight); iframe.height = height; }catch (ex){} }
html:
[u]复制代码[/u] 代码如下:
<iframe src="" id="weather" name="weather" width="278" onload="reSetIframe()" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" border="0" framespacing="0"> </iframe>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部