Quantcast
Viewing all articles
Browse latest Browse all 28

Answer by iMath for Resizing an iframe based on content

If you have control over the iframe content , I strongly recommend using

ResizeObserver

Just insert the following at the end of srcdoc attribute of iframe ,escape it if needed.

<script type="text/javascript">var ro = new ResizeObserver(entries => {  for (let entry of entries) {    const cr = entry.contentRect;    // console.log(window.frameElement);    window.frameElement.style.height =cr.height +30+"px";  }});ro.observe(document.body);</script>

Viewing all articles
Browse latest Browse all 28

Trending Articles