`

监听父窗口的变化自适应子页面的高度

F# 
阅读更多
<script>
/***********************监听iframe的onclik事件*****************/
var timeHandle;
function setEvent(){
try{
window.frames["childframe"].document.body.onclick=function(){
var f=document.getElementById('childframe');
   f.style.height = f.contentWindow.document.body.scrollHeight + "px";
}

}catch(e){}
timeHandle=setTimeout(setEvent,200);
}
setEvent();

/*************************装载的时候自适应高度************************/
function resizeFrame(f) {
  f.style.height = f.contentWindow.document.body.scrollHeight + "px";
 
}
</script>

  <iframe id=childframe  onload="resizeFrame(document.getElementById('childframe'))" scrolling="no" name=childframe src="yoursrc" width=100% height=100% frameborder=0 border=0 ></iframe>
分享到:
评论
1 楼 yangyunzhou 2010-08-15  
试了一下, 貌似不行

相关推荐

Global site tag (gtag.js) - Google Analytics