根据iframe的高度调整div的高度

时间:2014-02-10 20:47:15

标签: jquery html iframe height

我正在努力解决这个问题。我得到了这个页面 - http://www.wheelsmarket.ro/informatii - 如果你点击第三个名为“Baza de date PCD”的大按钮,会出现一个div。在那个div里面,是一个iframe。 iframe的来源与网站位于同一主机上。

我的问题是使父div(单击按钮时显示的那个)在iframe的高度函数中调整大小(如高度:auto)。

这是iframe src - http://wheelsmarket.ro/baza-date

这是代码@ iframe +父div

<div style="width:900px; height:100%" id="bazaDatePcd">
<iframe src="http://wheelsmarket.ro/baza-date" width="120%" height="100%"  marginheight="0" frameborder="0""></iframe>                  
<div id="spatiuCalc"></div>
<div class="clear"></div>
</div>

由于

1 个答案:

答案 0 :(得分:0)

抓住iFrames高度,然后将其应用于div;

var bazaDatePcd = document.getElementById('bazaDatePcd');
bazaDatePcd.style.height = bazaDatePcd.getElementsByTagName('iframe').offsetHeight;

将此绑定到按钮的onclick事件。

相关问题