﻿var iframeNames=["ihead","ifooter"];
var iframehide="yes";
function getWinHeight(win)
{
    var n1= win.document.compatMode == "CSS1Compat"? win.document.documentElement.scrollHeight : win.document.body.scrollHeight;
    var n2= win.document.compatMode == "CSS1Compat"? win.document.documentElement.clientHeight : win.document.body.clientHeight;
    return Math.max(n1,n2);
}
function setDomHeight(dom,height)
{
    dom.style.height=height+"px";
}
function dyniframesize() 
{    
    var dyniframe=[];
    for (i=0; i<iframeNames.length; i++)
    {
        var fDom=document.getElementById(iframeNames[i]);   //获取iframe's DOM
        var fWin=fDom.contentWindow;        //获取iframe's window    
        if(fWin.document.readyState=="complete")   //已经加载完成
        {
            var h=getWinHeight(fWin);
            setDomHeight(fDom,h);
        }
        else
        {
            fWin.onreadystatechange=function()
            {
                if(fWin.onreadystatechange=="complete")
                {
                    var h=getWinHeight(fWin);
                    setDomHeight(fDom,h);
                }
            }
        }        
    }
}
if (window.addEventListener)    window.addEventListener("load", dyniframesize, false);
else if (window.attachEvent)    window.attachEvent("onload", dyniframesize);
else window.onload = dyniframesize;


function reinitIframe() {
    var iframe = document.getElementById("frame_content");
    if (!iframe)
        iframe = document.getElementById("ifooter"); 
    try {

        var bHeight = iframe.contentWindow.document.body.scrollHeight;

        var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;

        var height = Math.max(bHeight, dHeight);

        iframe.height = height;

    } catch (ex) { }

}
window.setInterval("reinitIframe()", 200);

