【发布时间】:2018-10-13 14:46:04
【问题描述】:
我有很多 iframe,我希望每个 iframe 的 height 和 width 都与其内容相同。
例如:如果iframe 内容是1300x300,我需要在我的页面上iframe 将是1300x300。我正在从我的域加载 iframe。
【问题讨论】:
标签: javascript jquery angular typescript
我有很多 iframe,我希望每个 iframe 的 height 和 width 都与其内容相同。
例如:如果iframe 内容是1300x300,我需要在我的页面上iframe 将是1300x300。我正在从我的域加载 iframe。
【问题讨论】:
标签: javascript jquery angular typescript
尝试下面的代码并检查
// 加入有
<script>
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
//更改 iframe
<iframe src="..." frameborder="0" scrolling="no" onload="resizeIframe(this)" />
【讨论】: