手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >iframe 自适应高度[在IE6 IE7 FF下测试通过]
iframe 自适应高度[在IE6 IE7 FF下测试通过]
摘要:第一种方法:复制代码代码如下:第二种方法:jscode:复制代码代码如下://iframe自适应高度[在IE6IE7下测试通过]functi...

第一种方法:

复制代码 代码如下:

<script type="text/javascript" language="javascript">

<>

</script>

<iframe id="content01" name="content01" frameBorder=0 scrolling=no src="main.html" width="100%"onLoad="TuneHeight()" ></iframe>

第二种方法:

js code:

复制代码 代码如下:

//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:

复制代码 代码如下:

<iframe src="" id="weather" name="weather" width="278" onload="reSetIframe()" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" border="0" framespacing="0"> </iframe>

【iframe 自适应高度[在IE6 IE7 FF下测试通过]】相关文章:

JQuery中DOM实现事件移除的方法

jQuery实现给页面换肤的方法

JavaScript中的私有成员

JavaScript的正则表达式中test()方法的使用

JQuery控制Radio选中方法分析

如何实现iframe(嵌入式帧)的自适应高度

子父窗口之间的操作

JS/Jquery判断对象为空的方法

jQuery获取页面元素绝对与相对位置的方法

关于IFRAME 自适应高度的研究

精品推荐
分类导航