jQuery设置iframe的高度根据页面内容自适应

方式1:

    //注意:下面的代码是放在和iframe同一个页面中调用
    $("#iframeId").load(function () {
        var mainheight = $(this).contents().find("body").height() + 30;
        $(this).height(mainheight);
    });

方式2:

    //注意:下面的代码是放在iframe引用的子页面中调用
    $(window.parent.document).find("#iframeId").load(function () {
        var main = $(window.parent.document).find("#iframeId");
        var thisheight = $(document).height() + 30;
        main.height(thisheight);
    });
原文地址:https://www.cnblogs.com/qubernet/p/5673279.html