首頁  >  文章  >  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