Jquery - How do I dynamically adjust height of iframe?

喜夏-厌秋 提交于 2019-12-14 02:59:57

问题


I'm trying this code to adjust the height of an iframe to that of the browser window. I see dochit filling with the proper value, but it is not passing it to the iframe. When I use a <div> tag in place of the iframe, it resizes fine.

$(window).resize(function()  {
    var dochit = $(document).height();
    $("#pmividcon").css("height", dochit);
});

回答1:


You can set up a wrapper and then make the frame be 100% of it , check the jsfiddle

#wrapper {
    width:400px;
    height:400px;
}
#myFrame {
    height:100%;
    width:100%;
}

<div id="wrapper">
    <iframe src="http://www.jquery.com" id="myFrame" />
</div>

    var dochit = $(document).height();
$("#wrapper1 ").css({
     "height": dochit + "px
 });


来源:https://stackoverflow.com/questions/16745370/jquery-how-do-i-dynamically-adjust-height-of-iframe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!