问题
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