父页面iframe高度自动适应子页面iframe高度
function initParentHeight() { var div = window.parent.document.getElementById('mainFrame'); div.style.height=window.document.body.scrollHeight||window.document.body.offsetHeight+5; }
function SetWinHeight(obj)
{
var win=obj;
if (win && !window.opera)
{
if (win.contentWindow && win.contentWindow.document.body.offsetHeight) //ie 8
{
var height;
try{
var bheight=win.contentWindow.document.body.scrollHeight;
var dheight=win.contentWindow.document.documentElement.scrollHeight;
height=Math.max(bheight,dheight);
}catch(ex){}
win.style.height = height;
}
else if(win.Document && win.Document.body.scrollHeight)//ie 6
{
win.style.height = win.Document.body.scrollHeight;
}
}
initParentHeight();
}
哇塞,学习了,多谢