您的位置:首页 > 其它

iframe自适应高度

2015-12-16 17:37 323 查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>iframe自适应高度</title>
</head>
<body>
<div id="leamain">
<iframe src="#" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" width="765" height=100% id="iframepage" name="iframepage" onLoad="iFrameHeight()" ></iframe>
</div>

<script>
function iFrameHeight() {
var ifm= document.getElementById("iframepage");
var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;
if(ifm != null && subWeb != null) {
ifm.height = subWeb.body.scrollHeight;
}
}
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: