main.htm:

Iframe自适应其加载的内容高度_加载<html>  
Iframe自适应其加载的内容高度_加载    
<head>  
Iframe自适应其加载的内容高度_加载       
<meta  http-equiv=’Content-Type’  content=’text/html;  charset=gb2312’ />  Iframe自适应其加载的内容高度_加载       
Iframe自适应其加载的内容高度_加载       
<title>iframe自适应加载的页面高度title>  
Iframe自适应其加载的内容高度_加载    
head>  
Iframe自适应其加载的内容高度_加载     
Iframe自适应其加载的内容高度_加载    
<body>
Iframe自适应其加载的内容高度_加载        
<div><iframe src="child.htm">iframe>div>
Iframe自适应其加载的内容高度_加载    
body>
Iframe自适应其加载的内容高度_加载
html>

child.htm:

Iframe自适应其加载的内容高度_加载<html>  
Iframe自适应其加载的内容高度_加载
<head>  
Iframe自适应其加载的内容高度_加载    
<meta  http-equiv=’Content-Type’  content=’text/html;  charset=gb2312’ />  Iframe自适应其加载的内容高度_加载   
Iframe自适应其加载的内容高度_加载    
<title>iframe   自适应其加载的网页(多浏览器兼容)title>  
Iframe自适应其加载的内容高度_自适应高度_17Iframe自适应其加载的内容高度_浏览器兼容_18    
<script type="text/javascript">...
Iframe自适应其加载的内容高度_加载_19    

Iframe自适应其加载的内容高度_自适应_20
    
script>  
Iframe自适应其加载的内容高度_加载
head>  
Iframe自适应其加载的内容高度_加载
<body>
Iframe自适应其加载的内容高度_加载    
<table border="1" width="200" style="height: 400px; background-color: yellow">
Iframe自适应其加载的内容高度_加载        
<tr>
Iframe自适应其加载的内容高度_加载            
<td>iframe   自适应其加载的网页(多浏览器兼容:IE5.5+、Mozilla、Firefox、Opera、Netscape7.2+、Safari3等,支持XHTML)td>
Iframe自适应其加载的内容高度_加载        
tr>
Iframe自适应其加载的内容高度_加载    
table>
Iframe自适应其加载的内容高度_加载
body>  
Iframe自适应其加载的内容高度_加载
html>

  很多人反应在IE7里使用它会死机,那是因为在自适应高度时触发了 window.onresize 事件,而这个事件又去调用这个调整 > 高度的函数,产生了死循环调用。

  这段代码里我对 iframe 所在的父元素也设定了一个高度,以防止iframe 高度变化时页面跳动的太厉害,在调用的时候可酌情使用这个设置。