运行代码 缩小
汉王
HTML代码
复制 格式化 注释 注释 清空
放大
AخA
 
1
<html>
2
<head>
3
<title>iframe 自适应高度</title>
4
<script type="text/javascript">
5
function SetCwinHeight(){
6
var bobo=document.getElementById("main”); //iframe id
7
if (document.getElementById){
8
if (bobo && !window.opera){
9
if(bobo.contentDocument && bobo.contentDocument.body.offsetHeight){
10
bobo.height = bobo.contentDocument.body.offsetHeight;
11
}else if(bobo.Document && bobo.Document.body.scrollHeight){
12
bobo.height = bobo.Document.body.scrollHeight+30;
13
//alert(document.getElementById(“amdright”).style.width);
14
}
15
}
16
}
17
}
18
</script>
19
</head>
20
<body>
21
<iframe id="main" name="main"  src="http://www.baidu.com" scrolling="no" width="100%" frameborder="0" onload="SetCwinHeight()"></iframe>
22
</body>
23
</html>
CSS代码
复制 格式化 注释 注释 颜色 清空
放大
CSS代码...
x
 
1
JS代码
复制 格式化 注释 注释 清空
放大
JS代码...
xxxxxxxxxx
1
 
1
名称
iframe 自适应高度,代码兼容IE和Firefox
分类
网站常用
描述
iframe 自适应高度,代码兼容IE和Firefox
收藏