Home > Web Front-end > JS Tutorial > JavaScript application: Iframe adapts to the height of its loaded content_javascript skills

JavaScript application: Iframe adapts to the height of its loaded content_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 19:15:11
Original
1060 people have browsed it
main.htm:
Copy code The code is as follows:

< html>  
                                                     'F.R.Huang(meizz梅花雪)//www.meizz.com'>                                                                                       >                                                                      

child.htm:



(Multi-browser compatible)
{
var a = parent.document.getElementsByTagName("IFRAME");
for(var i=0; i {
if(a[i].contentWindow==window)
{
var h = document.body.scrollHeight; if(document .all) {h = 4;}
                                                                      .opera) {h = 1;}
a[i].style.height = h;
}
}
}
catch (ex)
{
alert("Script cannot be operated across domains! ");
}
}
if(document.attachEvent) window.attachEvent("onload", iframeAutoFit);
else window.addEventListener('load', iframeAutoFit, false);




iframe Adapt to the web page it loads (compatible with multiple browsers)



Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template