html
代码为:
<iframe src="iframe_Mall.html" frameborder="0" width=100% id="iframeBox" name="iframeBox" scrolling="no" ></iframe>
子页面上script
代码
function iFrameHeight() {
//获取iframe框架
var iframeBox = window.parent.document.getElementById("iframeBox");
//获取子页面文档高度
var iframeBodyHeight = window.document.documentElement.scrollHeight;
//这里定义下iframe框架高度
iframeBox.height = 5000;
//打印出iframe文档高度
console.log("after" + iframeBodyHeight)
// 就是这里出了问题,
// IE和火狐下,除了第一次执行是准确的,后面打印出来都是5000,
// 这就导致了,window调整大小的时候,只会增加iframe框架的高度
// 谷歌 360 Oprea 下是正常的
}
iFrameHeight();
//窗口调整时,重新计算文档高度
$(window).resize(function() {
iFrameHeight();
});
所以,想问下各位大神,iframe框架高度变化的时候,会影响里面的文档高度吗?
已经折腾一下午,快崩溃了。