1. 程式人生 > >ifream載入完成後根據實際高度載入ifream高度 避免出現多個滾動條

ifream載入完成後根據實際高度載入ifream高度 避免出現多個滾動條

$("#iframe_280").on("load",function(){   //  iframe載入完後(防止你的ifream還沒有載入完成 報錯) 高度自適應。
            debugger;
            var frameObj = document.getElementById("iframe_280").contentDocument ||                                                                                                             document.getElementById("iframe_280").contentWindow.document;


            var mainWrapHeight = $(window).height() - 49 - 21;


            var frame_height = frameObj.documentElement.scrollHeight;  


            $("#iframe_280").height( frame_height < 860 ? mainWrapHeight : frame_height);
         });