<iframe>框架头部加<!doctype html>,js自适应高度就失效了,这是为什么
这个页面头部为什么加<!doctype html>这个,js自适应高度就失效了呢
------解决思路----------------------
subWeb.documentElement.scrollHeight
<html>
<head>
<meta charset="utf-8">
<title>简介</title>
<style type="text/css">
div#leamain {
text-align: center
};
</style>
</head>
<body>
<script type="text/javascript" language="javascript">
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>
<div id="leamain">
<iframe src="http://www.xxx.com/xxx.html" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" width="950" height=100% id="iframepage" name="iframepage" onLoad="iFrameHeight()" ></iframe>
</div>
</body></html>
这个页面头部为什么加<!doctype html>这个,js自适应高度就失效了呢
------解决思路----------------------
subWeb.documentElement.scrollHeight