解决iframe自适应高度

其实很简单,所以高手就不看了哈

方法一:

< iframe id = " ifr "  name = " ifr "  src = " ifr_content.jsp "   frameborder = " 0 "  scrolling = " no "
        onload = " this.style.height=ifr.document.body.scrollHeight+50 "  height = " auto "  width = " 100% " ></ iframe >

 

 方法二:

< body onloade = " IFrameResize() " >
< iframe id = " ifr "  name = " ifr "  src = " ifr_content.jsp> "   frameborder = " 0 "  scrolling = " no "
height = " auto "  width = " 100% " ></ iframe >
                            
< script >
                                function IFrameResize(){
                                    var obj  =  parent.document.getElementById( " ifr " );   // 取得父页面IFrame对象
                                    obj.height  =   this .document.body.scrollHeight;   // 调整父页面中IFrame的高度为此页面的高度
                                }
                            
</ script >
 
</ body >

 

 

你可能感兴趣的:(iframe)