iframe高度自适应

 

 

function SetWinHeight(obj) {

var win = obj;

if(document.getElementById) {

if(win && !window.opera) {

if(win.contentDocument && win.contentDocument.body.offsetHeight) {

win.height = win.contentDocument.body.offsetHeight;

} else if(win.Document && win.Document.body.scrollHeight)

win.height = win.Document.body.scrollHeight;

}

}

}

 

iframe引用的方式

<iframe onload="javascript:SetWinHeight(this)" scrolling="no" 

name="contentFrame" id="contentFrame" border="none" 

frameborder="no" src="test.html"

width="100%"/>

 

你可能感兴趣的:(iframe js)