Method 1:
The code copy is as follows:
$(window.parent.document).find("#ContentIframe").load(function() {
var main = $(window.parent.document).find("#ContentIframe");
var thisheight = $(document).height();
if (thishight < 800)
thisheight = 800;
main.height(thishight);
});
This writing method can only adapt to the adaptive height of the inherent elements when loading. When the element changes (such as adding many elements, after the height changes), the iframe height of the parent form cannot be changed in time.
Method 2:
The code copy is as follows:
function setMainHeight() {
var main = $(window.parent.document).find("#ContentIframe");
var thisheight = $("body").height();
if (thishight < 800) { thisheight = 800; }
main.height(thishight+50);
setTimeout(setMainHeight, 2000);
}
Add a timer to poll to determine the height change of the subpage.
The above two types can be highly adaptable by iframes. Friends, please choose freely according to their project needs.