Iframe高度自适应 – 设计之家 //www.laura-marie.com 传播先进设计理念 推动原创设计发展 Sun, 20 Apr 2008 15:01:00 +0000 zh-Hans hourly 1 https://wordpress.org/?v=6.9.4 Iframe高度自适应代码 //www.laura-marie.com/15647.html //www.laura-marie.com/15647.html#respond Sun, 20 Apr 2008 15:01:00 +0000 Iframe高度自适应 IE与FF环境下均可用

  看下面的代码:

<script type=”text/javascript”>
 function SetCwinHeight(){
  var bobo=document.getElementById(“bobo”); //iframe id
  if (document.getElementById){
   if (bobo && !window.opera){
    if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){
     bobo.height = bobo.contentDocument.body.offsetHeight;
    }else if(bobo.Document && bobo.Document.body.scrollHeight){
     bobo.height = bobo.Document.body.scrollHeight;
    }
   }
  }
 }
</script>
<iframe width=”100%” id=”bobo” onload=”Javascript:SetCwinHeight()” height=”1″ frameborder=”0″ src=”//www.laura-marie.com/”></iframe>

查看运行效果:


    [ 可先修改部分代码 再运行查看效果 ]

]]>
//www.laura-marie.com/15647.html/feed 0