【发布时间】:2016-06-17 08:30:41
【问题描述】:
我有以下代码:-
<script language="javascript" type="text/javascript">
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
<div class="resizable">
<iframe src="http://yellow-taxi.co.uk/onlinebooking/index.php" frameborder="0" width="100%" height="100%" scrolling="no" onload="resizeIframe(this)"></iframe>
</div>
Javascript 会将高度调整为 iFrame 的初始高度,但 iFrame 的高度会随着您完成预订过程而增加。有没有办法根据内容变化自动调整 iFrame 的高度?
注意: iFrame 与 iFrame src 显示在同一域中。
【问题讨论】:
-
您有任何可用的 javascript 库 (jQuery) 吗?
-
是
jquery-1.9.1.js
标签: javascript jquery html iframe