Iframe自适应记录

      function reinitIframe(){
        //$("#external-frame").height = $(document.body).height();
    try{
        var iframe = document.getElementById("external-frame");
        if(iframe.attachEvent){
            iframe.attachEvent("onload", function(){
                iframe.height =  iframe.contentWindow.document.documentElement.scrollHeight;
            });
            return;
        }else{
            iframe.onload = function(){
                iframe.height = iframe.contentDocument.body.scrollHeight;
            };
            return;                 
        }     
    }catch(e){
        throw new Error('setIframeHeight Error');
    }
    }

发布了28 篇原创文章 · 获赞 7 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/boke7265/article/details/104374261
今日推荐