Adaptive page Height

Source: Internet
Author: User
Tags window
Page | adaptive

Main.htm:

<meta http-equiv= ' content-type ' content= ' text/html; charset=gb2312 '/>
<meta name= ' author ' content= ' F.r.huang (meizz plum blossom Snow)//www.meizz.com '/>
<title>iframe Adaptive Load Page height </title>

<body>
<div><iframe src= "child.htm" ></iframe></div>
</body>

Child.htm:

<meta http-equiv= ' content-type ' content= ' text/html; charset=gb2312 '/>
<meta name= ' author ' content= ' F.r.huang (meizz plum blossom Snow)//www.meizz.com '/>
<title>iframe Adaptive to its loaded Web page (multi-browser compatible) </title>
<script type= "Text/javascript" >
<!--
function Iframeautofit ()
{
Try
{
if (window!=parent)
{
var a = Parent.document.getElementsByTagName ("IFRAME");
for (var i=0; i<a.length; i++)//author:meizz
{
if (A[i].contentwindow==window)
{
var h1=0, h2=0;
A[i].parentnode.style.height = a[i].offsetheight + "px";
A[i].style.height = "10px";
if (document.documentelement&&document.documentelement.scrollheight)
{
H1=document.documentelement.scrollheight;
}
if (document.body) h2=document.body.scrollheight;

var H=math.max (H1, H2);
if (document.all) {h = 4;}
if (window.opera) {h = 1;}
A[i].style.height = A[i].parentnode.style.height = h + "px";
}
}
}
}
catch (ex) {}
}
if (window.attachevent)
{
Window.attachevent ("onload", Iframeautofit);
Window.attachevent ("OnResize", Iframeautofit);
}
else if (Window.addeventlistener)
{
Window.addeventlistener (' Load ', Iframeautofit, false);
Window.addeventlistener (' Resize ', Iframeautofit, false);
}
-->
</script>
<body>
<table border= "1" width= "style=" height:400px; Background-color:yellow ">
<tr>
<td>iframe Adaptive to its loaded Web page (multi-browser compatible, support XHTML) </td>
</tr>
</table>
</body>

Many people react to IE7 using it to panic because the Window.onresize event is triggered when the altitude is adaptive, and this event calls the adjustment <iframe> height function, resulting in a dead loop call.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.