Resizing an iframe based on content

后端 未结 21 2801
南方客
南方客 2020-11-21 07:40

I am working on an iGoogle-like application. Content from other applications (on other domains) is shown using iframes.

How do I resize the iframes to fit the heigh

21条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-21 07:57

    Work with jquery on load (cross browser):

     
    
    function loaderIframe(){
    var heightIframe = $('#containiframe').contents().find('body').height();
    $('#frame').css("height", heightFrame);
     }  
    

    on resize in responsive page:

    $(window).resize(function(){
    if($('#containiframe').length !== 0) {
    var heightIframe = $('#containiframe').contents().find('body').height();
     $('#frame').css("height", heightFrame);
    }
    });
    

提交回复
热议问题