Javascript Iframe获得可见大小

Javascript Iframe获得可见大小,javascript,jquery,html,css,Javascript,Jquery,Html,Css,在iframe中,我需要弄清楚视觉尺寸到底是多少(使用js或jquery) 在本例中,仅显示iframe的一部分。 Iframe大小为300x300,但div将其限制为300x100 <div style="max-width: 300px; max-height: 100px; overflow: hidden"> <iframe width="300" height="300" src="http://www.rapidtables.com/web/tools/window

在iframe中,我需要弄清楚视觉尺寸到底是多少(使用js或jquery)

在本例中,仅显示iframe的一部分。 Iframe大小为300x300,但div将其限制为300x100

<div style="max-width: 300px; max-height: 100px; overflow: hidden">
<iframe width="300" height="300" src="http://www.rapidtables.com/web/tools/window-size.htm" style="border:none"></iframe>
</div>

首先将ID添加到iframe:

<div style="max-width: 300px; max-height: 100px; overflow: hidden">
<iframe id="myIframe"width="300" height="300" src="http://www.rapidtables.com/web/tools/window-size.htm" style="border:none"></iframe>
</div>

我想这会帮助你:不,这会给我一个iframe的大小,我不需要。如您所见,只显示了iframe的一部分。我需要那部分,你看这里了吗。问题中提到了“parent.document.body.clientHeight”.height()。只需要iframe的可见部分。
<div style="max-width: 300px; max-height: 100px; overflow: hidden">
<iframe id="myIframe"width="300" height="300" src="http://www.rapidtables.com/web/tools/window-size.htm" style="border:none"></iframe>
</div>
$('#myIframe').contents().find('body').height()