function SetCwinHeight(){ var iframeid=document.getElementById("iframeId");//所要自适应高度的iframe的id if (document.getElementById){ if (iframeid && !window.opera){ if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight){ iframeid.height = iframeid.contentDocument.body.offsetHeight; }else if(iframeid.Document && iframeid.Document.body.scrollHeight){ iframeid.height = iframeid.Document.body.scrollHeight; } } } }
<iframe onload="Javascript:SetCwinHeight()" src="url" name="orderInfoFrame" id="orderInfoFrame" frameborder="0" style="Z-INDEX: 1; VISIBILITY: inherit; WIDTH: 100%;" scrolling="no" ></iframe>
注意去掉<iframe> 中的height值,用onload调用所写的js。