//dom完成事件。
$(function(){
//根据tree节点的新增事件,执行iframe的高度变化
$("#tree").bind('DOMNodeInserted',function(){
//判断存在父页面。
if(window.parent != window){
// console.log("body.scrollHeight:"+document.body.scrollHeight);
// console.log("tree-height:"+document.getElementById("tree").scrollHeight);
parent.document.getElementById("treeBottomIframe").style.height = (document.getElementById("tree").scrollHeight +100)+"px";
}
});
//dom加载完成后第一次自适应高度
if(window.parent != window){
console.log("dom:"+document.body.scrollHeight);
parent.document.getElementById("treeBottomIframe").style.height = (document.body.scrollHeight)+"px";
}
});
在去除iframe滚动条之后,内容过高又不显示滚动条的情况下, 把这个逻辑加到子页面中,可以实时的修改父页面中该iframe的高度,以展示所有的内容。 treeBottomIframe是存放子页面的iframe的id。 tree是子页面中存在节点变动的div的id。