首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

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

2012-11-23 
监听父窗口的变化自适应子页面的高度script/***********************监听iframe的onclik事件***********

监听父窗口的变化自适应子页面的高度
<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   试了一下, 貌似不行

热点排行