在iframe的页面里面加上window.onload=function(){
if(document.body.scrollHeight>3000)
parent.document.all.iframeName.style.height=document.body.scrollHeight;
else
parent.document.all.iframeName.style.height=3000;
}
if(document.body.scrollHeight>3000)
parent.document.all.iframeName.style.height=document.body.scrollHeight;
else
parent.document.all.iframeName.style.height=3000;
}
<body onLoad="parent.document.demo.height= document.body.scrollHeight">
parent.document.all.tags("IFRAME")[window.name].height=document.body.scrollHeight;
前提是父文档中没有重名的iframe对象.
这种方式避免了父文档在控制子文档的时候,对子文档状态进行判断的问题.