Resize iframe to content with Jquery

前端 未结 6 2099
孤街浪徒
孤街浪徒 2020-12-03 18:08

I\'m trying to resize an iframe dynamicly to fit its content. To do so I have a piece of code:

$(\"#IframeId\").height($(\"#IframeId\").contents().find(\"htm         


        
6条回答
  •  有刺的猬
    2020-12-03 18:56

    Just do it on the HTML tag, works perfect

    $("#iframe").load(function() {
        $(this).height( $(this).contents().find("html").height() );
    });
    

提交回复
热议问题