IFRAME Adaptive altitude [IE6 IE7 FF test through]_javascript tips

Source: Internet
Author: User
The first method:
Copy Code code as follows:

<script type= "Text/javascript" language= "JavaScript" >
<!--
Adjust the height of the PageContent
function Tuneheight () {
var frm = document.getElementById ("content01");
var subweb = Document.frames? document.frames["content01"].document:frm.contentdocument;
if (frm!= null && subweb!= null) {
Frm.height = SubWeb.body.scrollHeight;
}
}
-->
</script>

<iframe id= "content01" name= "content01" frameborder=0 scrolling=no src= "main.html" width= "100%" onload= "Tuneheight" () "></iframe>

The second method:
JS Code:
Copy Code code as follows:

IFRAME adaptive height [tested through 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:
Copy Code code as follows:

<iframe src= "" id= "weather" name= "weather" width= "278" onload= "Resetiframe ()" marginwidth= "0" marginheight= "0" Scrolling= "No" frameborder= "0" border= "0" framespacing= "0" > </iframe>

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.