javascript: iframe 自适应高度(多浏览器兼容)
iframe.html
Code
child.html
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312' />
<script language="javascript">
function f_frameStyleResize(targObj){
var targWin = targObj.parent.document.getElementById(targObj.name);
if(targWin != null) {
var HeightValue = targObj.document.body.scrollHeight
if(HeightValue < 600){HeightValue = 600}
targWin.style.height = HeightValue;
}
}
function f_iframeResize(){
bLoadComplete = true; f_frameStyleResize(self);
}
var bLoadComplete = false;
window.onload = f_iframeResize;
</script>
</head>
<body>
<table border="1" width="200" style="height: 600px; background-color: yellow">
<tr>
<td>iframe 自适应其加载的网页(多浏览器兼容:IE5.5+、Mozilla、Firefox、Opera、Netscape7.2+、Safari3等,支持XHTML)</td>
</tr>
</table>
</body>
</html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312' />
<script language="javascript">
function f_frameStyleResize(targObj){
var targWin = targObj.parent.document.getElementById(targObj.name);
if(targWin != null) {
var HeightValue = targObj.document.body.scrollHeight
if(HeightValue < 600){HeightValue = 600}
targWin.style.height = HeightValue;
}
}
function f_iframeResize(){
bLoadComplete = true; f_frameStyleResize(self);
}
var bLoadComplete = false;
window.onload = f_iframeResize;
</script>
</head>
<body>
<table border="1" width="200" style="height: 600px; background-color: yellow">
<tr>
<td>iframe 自适应其加载的网页(多浏览器兼容:IE5.5+、Mozilla、Firefox、Opera、Netscape7.2+、Safari3等,支持XHTML)</td>
</tr>
</table>
</body>
</html>