Control iframe height with jQuery

后端 未结 9 1733
情书的邮戳
情书的邮戳 2020-12-13 07:32

I am using jQuery to control the height of an iframe.

jQuery(\"iframe\",top.document).contents().height();  

This works when the height of

9条回答
  •  借酒劲吻你
    2020-12-13 08:03

    This is a simple jQuery that worked for me. Tested in iExplorer, Firefox and Crome:

     $('#my_frame').load(function () {  
          $(this).height($(this).contents().find("html").height()+20);
    });
    

    I add 20 pixels just to avoid any scroll bar, but you may try a lower bound.

提交回复
热议问题