iframe高度自适应

< iframe src="index.html" id="iframepage" frameborder="0" scrolling="no"
marginheight="0" marginwidth="0" onLoad="iFrameHeight()"></ iframe >
 
function iFrameHeight() {  
var ifm= document.getElementById( "iframepage" );  
var subWeb = document.frames ? document.frames[ "iframepage" ].document : ifm.contentDocument;  
if (ifm != null && subWeb != null ) {
    ifm.height = subWeb.body.scrollHeight;
    ifm.width = subWeb.body.scrollWidth;
}  

}

猜你喜欢

转载自15757126299.iteye.com/blog/2265850