Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (20.3k points)

For example:

<iframe name="Stack" src="http://stackoverflow.com/" width="740"

        frameborder="0" scrolling="no" id="iframe"> ...

</iframe>

I want it to be able to adjust its height according to the contents inside it, without using the scroll.

1 Answer

0 votes
by (40.7k points)

You can try adding this to your <head> section:

<script>

  function resizeIframe(obj) {

    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';

  }

</script>

And try changing your iframe like this:

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

Related questions

Browse Categories

...