Iframe 默认高度、宽度

  项目中还在使用 Iframe ,一次看代码时发现 Iframe 没有指定高度、宽度,可是在页面上显示的时候却有高度、宽度。想着应该是 Iframe 的默认值,于是写了一个简单的页面,代码如下:

 1 <!DOCTYPE html>
 2 <html>
 3 <head>    
 4     <script type="text/javascript">
 5         function aaa() {
 6             //alert(0);
 7             alert("document.getElementById('Iframe2').clientHeight:" + document.getElementById("Iframe2").clientHeight);
 8             alert("document.getElementById('Iframe2').clientWidth:" + document.getElementById("Iframe2").clientWidth);
 9         }
10     </script>
11 </head>
12 <body onload="aaa()">    
13     <iframe name="Iframe2" id="Iframe2" src="" style="" scrolling="yes"></iframe>
14     
15 </body>
16 
17 </html>

在 Firefox、Chorme、IE 上试了下显示的值都是 Height:150、Weight:300.

posted on 2014-04-01 11:06  thegavincheng  阅读(2144)  评论(0编辑  收藏  举报