iframe自适应高度

框架html代码:

<iframe id="report_iframe" frameborder="0" name="report_iframe" src="<{$adminpage}>?m=index" width="100%" onload="iFrameHeight()"></iframe>

js代码:

function iFrameHeight() {
    var ifm= document.getElementById("report_iframe");
    var subWeb = document.frames ? document.frames["report_iframe"].document : ifm.contentDocument;
    if(ifm != null && subWeb != null) {
        ifm.height = subWeb.body.scrollHeight;
        ifm.width = subWeb.body.scrollWidth;
    }
}