Home > Article > Web Front-end > Using javascript to implement Iframe adaptive height_javascript skills
Method 1:
This way of writing can only adapt the height of the inherent element when loading. When the element changes (such as adding a lot of elements and the height changes), the iframe height of the parent form cannot be changed in time.
Method 2:
var main = $(window.parent.document).find("#ContentIframe");
var thisheight = $("body").height();
If (thisheight < 800) { thisheight = 800; }
Main.height(thisheight 50);
setTimeout(setMainHeight, 2000);
}
Add a timer to poll to determine the height change of the subpage.
Both of the above two can be iframes to achieve high adaptability. Friends, feel free to choose according to your own project needs