首页  >  文章  >  web前端  >  iframe 自适应高度[在IE6 IE7 FF下测试通过]_javascript技巧

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

WBOY
WBOY原创
2016-05-16 18:54:17784浏览

第一种方法:

复制代码 代码如下:





第二种方法:
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:
复制代码 代码如下:


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn