Home  >  Article  >  Web Front-end  >  iframe adaptive height [passed test under IE6 IE7 FF]_javascript skills

iframe adaptive height [passed test under IE6 IE7 FF]_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:54:17813browse

The first method:

Copy the code The code is as follows:





Second method:
js code :
Copy code The code is as follows:

//iframe adaptive height [under IE6 IE7 Test passed]
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:
Copy code The code is as follows:


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn