Multiple IFRAME Automatic sizing problem _ form effects

Source: Internet
Author: User
One page I have multiple iframe, and each iframe src is different, height is not the same.
How to use a function to automatically adjust the height of all the iframe in this page?

function Change_size (IFRAME)
{
iframe.style.height=info_content.document.body.scrollheight+1+ "px";
}
I've used this approach, but the first object after the equals sign doesn't know how to display it dynamically.
Like what:
function Change_size (NO)
{
var el_name = "iframe" +NO;
el = document.getElementById (El_name);
El. style.height=el.document.body.scrollheight+1+ "px";
For example, the height cannot actually be adjusted because the following El cannot point to the correct object
}

So now I'm using this method for a while, for each IFRAME.
A.style.height = Iframe_a.document.body.scrollHeight
B.style.height = Iframe_b.document.body.scrollHeight

Hope you can give a more simple method, I lifted JS not long, may be a little silly, please forgive me.
It feels like you're going to have a problem with this automatic adjustment.
If the parent page is loaded and the child page is not loaded, the height of the iframe you control is definitely not what you think.

If your subpages and parent pages are under a single domain name, you can recommend an easy way.

Set a function in the parent page to adjust the height of a ifame, and then call this function of the parent page in the body onload of the child page. This must be the Wait child page is loaded at the height of the setting, this can be set to the actual height of the child page.

Set height code for parent page, not tested
Copy Code code as follows:

function Setparentframeheight (frameid,height) {
var frame= document.getElementById (Frameid);
Frame.style.height = height;//actual height can be obtained in the body of the child page
}
Related Article

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.