<!--iframe自适应高度 -->
<!--方法1-->
<iframe frameBorder="0" id="mainiframe" name="mainiframe" src="jsp/welcome.jsp" οnlοad="this.height=mainiframe.document.body.scrollHeight" scrolling="no"></iframe>
<!--方法2-->
οnlοad="iframeh()"
js中写入方法
function iframeh() {
document.getElementById('mainiframe').style.height = mainiframe.document.body.scrollHeight + 'px';
}
<!--方法3-->
οnlοad="AutoIframe()"
js中写入方法
function AutoIframe(){
if(document.readyState!='complete'){
setTimeout( function(){AutoIframe();},25 );
return;
} else {
var ifobj=document.getElementById("mainiframe");
ifobj.height= ifobj.contentWindow.document.body.scrollHeight;
}
}
iframe自适应高度
最新推荐文章于 2024-03-29 11:18:46 发布