框架自适应高度

<iframe id="myiframe" width="100%"
                    frameborder="0" marginwidth="0" marginheight="0" src="../News.aspx" allowtransparency="true"
                    scrolling="no"></iframe>

 

 function InitFrameHeight(){  
                 var iframe = document.getElementById("myiframe");  
                try{  
                     var bHeight = iframe.contentWindow.document.body.scrollHeight;  
                     var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;  
                     var height = Math.max(bHeight, dHeight);  
                    iframe.height =  height;  
                 }catch (ex){}  
             }
             window.setInterval("InitFrameHeight()", 200);

你可能感兴趣的:(自适应)