iframe宽度高度的自适应的问题

iframe嵌套在div内 ,iframe的宽高都设置了100% ,可是还是无法自适应,解决方法如下:

代码:通过红色位置可以解决

function setIframeHeight(iframeId){  
    var cwin = document.getElementById(iframeId);   
    if (document.getElementById){  
        if (cwin && !window.opera){  
            if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight){  
                cwin.height = cwin.contentDocument.body.offsetHeight + 20; //FF NS   
            }  
            else if(cwin.Document && cwin.Document.body.scrollHeight){  
                cwin.height = cwin.Document.body.scrollHeight + 10;//IE   
            }  
        }else{  
            if(cwin.contentWindow.document && cwin.contentWindow.document.body.scrollHeight)   
            cwin.height = cwin.contentWindow.document.body.scrollHeight;//Opera   
        }  
    }   
};  


window.οnlοad=function(){
  var a=document.body.clientHeight-182;  //取得iframe框架的实际宽度
  document.getElementById("right").style.height=a+"px";
}


 




你可能感兴趣的:(jquery,+,js,+,ajax)