iframe 自适应高度宽度 ie7

iframe 自适应高度宽度 ie7

function reSetIframe(){

    var iframe = document.getElementById("iframe1");

    try{

        var bHeight = iframe.contentWindow.document.body.scrollHeight;

        var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;


        var bWidth= iframe.contentWindow.document.body.scrollWidth;

        var dWidth=iframe.contentWindow.document.documentElement.scrollWidth;

        var height = Math.max(bHeight, dHeight);

        var width= Math.max(bWidth, dWidth);

        iframe.height =  height;

        iframe.width=width;

    }catch (ex){}

}


<iframe name='iframe1' id='ifrme1' onload="reSetIframe()" frameborder="0" scrolling="no"  src="<%=basePath %>pages/blank.htm"></iframe>


他奶奶的 找了半天 才找到 先记下 



你可能感兴趣的:(iframe 自适应高度宽度 ie7)