JS实现iframe自适应高度
在父窗口设置子元素iframe的宽度:
function SetIframeHeight() {
var task = document.getElementById('task');
var error = document.getElementById('error');
var synopsis = document.getElementById('synopsis');
try{
task.height = task.contentWindow.document.body.clientHeight;
error.height = error.contentWindow.document.body.clientHeight;
synopsis.height = synopsis.contentWindow.document.body.clientHeight;
}catch (ex){}
}
获取iframe的子元素
document.getElementById('frameId').contentDocument.getElementById('treeDemo')