Angular 5 iframe设置的宽度和高度与其内容相同

时间:2018-05-03 10:13:31

标签: javascript jquery angular typescript

我有很多iframe,我希望iframe中的每一个都有heightwidth相同的内容。

例如:如果iframe内容为1300x300,我需要在我的网页上iframe1300x300。我正在加载来自我的域名的iframe。

1 个答案:

答案 0 :(得分:0)

尝试以下代码并检查

//添加

<script>
  function resizeIframe(obj) {
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
  }
</script>

//更改iframe

<iframe src="..." frameborder="0" scrolling="no" onload="resizeIframe(this)" />
相关问题