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="/default.asp?cateID=1"></iframe>

原文地址:https://www.cnblogs.com/ANDY_ZHANG/p/1872065.html