I have multiple iframes on one page, and the src and height of each iframe are different.
How to use a function to automatically adjust the height of all iframes in this page?
function change_size(iframe)
{
iframe.style.height=info_content.document.body.scrollHeight 1 "px";
}
I have used this method, But the first object after the equal sign doesn't know how to dynamically display it.
For example:
function change_size(no)
{
var el_name = "iframe" no;
el = document.getElementById(el_name);
el .style.he ight=el .document.body.scrollHeight 1 "px";
// For example, the height cannot be adjusted because the el behind cannot point to the correct object
}
So I am temporarily using this Method, used once for each iframe
a.style.height = iframe_a.document.body.scrollHeight
b.style.height = iframe_b.document.body.scrollHeight
I hope you can give A simpler method. It hasn't been long since I deactivated js. The question may be a bit stupid, please forgive me.
It feels like the automatic adjustment you wrote like this will cause problems.
If the parent page is loaded but the child page is not loaded, the height of the iframe you control will definitely not be the height you want.
If your subpage and parent page are under the same domain name, I recommend a simple method for you.
Set a function in the parent page to adjust the height of a certain ifame, and then add it to the subpage This function of the parent page is called in body onload. This must wait until the sub-page is loaded and the height is set, so that it can be set to the actual height of the sub-page.
//Height setting code of the parent page, not tested