版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/HY_358116732/article/details/79021995
方法一:
在和iframe同一个页面中调用
$("#iframeId").load(function () {方法二:
var mainheight = $(this).contents().find("body").height() + 30;
$(this).height(mainheight);
});
在iframe引用的子页面中调用
$(window.parent.document).find("#iframeId").load(function () {
var main = $(window.parent.document).find("#iframeId");
var thisheight = $(document).height() + 30;
main.height(thisheight);
});