div iframe
问题是这样的,我现在有一个iframe写在了一个div层里。 div 不设置高度 iframe 高度自适应 。http://download.csdn.net/detail/stongyann/4958175
把div的style去掉就是默认全屏。
<div style="width:800px; height:600px;"><iframe style="display:none;" id="iframeInfo" name="iframeInfo" onload="javascript:{dyniframesize('iframeInfo');}" marginwidth="0" marginheight="0" height="100%" width="100%" scrolling="auto" frameborder="0" src="http://www.baidu.com"></iframe></div><script language="javascript"> var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]; //extra height in px to add to iframe in FireFox 1.0+ browsers var FFextraHeight=getFFVersion>=0.1? 16 : 0 ; function dyniframesize(iframename) { var pTar = null; if (document.getElementById){ pTar = document.getElementById(iframename); } else{ eval('pTar = ' + iframename + ';'); } if (pTar && !window.opera){ //begin resizing iframe pTar.style.display="block"; if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){ //ns6 syntax pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight; } else if (pTar.Document && pTar.Document.body.scrollHeight){ //ie5+ syntax pTar.height = pTar.Document.body.scrollHeight; } } }</script>