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
}