jQuery,jsはIframe適応高さを実現(マルチブラウズ対応)


//私たちはaa.htmlの中にiframeがあり、ロード内容はbbです.html

<iframe id="frame_con" src="bb.html" frameborder=0 scrolling=no style="margin-left:0px;margin-top:-3px;width:785px;height:550px;float:right;"></iframe>

方式一

//  jQuery
<script src="http://res.func.fetionpictest.com/js/public/jquery-1.3.2.min.js?2011122701" type="text/javascript"></script>
<script type="text/javascript">
          //document.domain = "fx-func.com";//    
         $(window.parent.document).find("#frame_con").load(function(){//    
         var main = $(window.parent.document).find("#frame_con");//  iframe  
         var thisheight = $(document).height()+30;//      
         main.height(thisheight < 500 ? 500 : thisheight);
// iframe          500,   500,     ,   
                });
     </script>

方式2

$("#frame_con").load(function(){
    var thisheight = $(this).contents().find("body").height()+30;
    $(this).height(thisheight < 500 ? 500 : thisheight);
});