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')
原文地址:https://www.cnblogs.com/yoomin/p/3732658.html