iFrame在chrome中高度的问题。

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

 JS中加上面代码,iframe 加下面代码。

 <iframe id="main_if" src="@Url.Action("indexInfo")"  frameborder="0" scrolling="no" marginheight="0" marginwidth="0" onLoad="iFrameHeight()"></iframe>

之前真不知道 Iframe在chrome中 还有这毛病。还是IE好。

原文地址:https://www.cnblogs.com/qq22144770/p/4800320.html