jQuery解决iframe高度自适应代码

网上查了好多用着都不行,自己搞定了:在包含iframe的页面中加入以下脚本,基本思想是在iframe加载内容后重新设置高度,下面代码尽在IE6中用过,没在其他浏览器中测试。
代码如下:

<script type="text/javascript"> 
<!-- 
$( 
    function() 
    {                     
     //iframe高度随内容自动调整 
        $('.main').load( 
         function() 
            { 
                $(this).height($(this).contents().find("body").attr('scrollHeight')); 
            } 
        ); 
    } 
);      
// --> 
</script>

原文地址:https://www.cnblogs.com/webenh/p/6224491.html