0

I have an iframe on a site that I'm building. Problem is, one of the pages I display inside the frame has some dynamic content (that expands and decreases in height when clicked), is there a way for the iframe to resize along with its content too?

It loads the size of the static page but once the item on page has been clicked and expands, the iframe doesn't expand with it.

I just have it basic at the moment, here is my <head> content:

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

And this is my iframe:

<iframe src="index2.php" name="frame" frameborder="0" scrolling="no" onload="resizeIframe(this)" />
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Drew
  • 1
  • 1
  • Hello and welcome to StackOverflow! It would be helpful to provide a [minimal, complete and verifiable example](http://stackoverflow.com/help/mcve). – Jia Jian Goi Dec 18 '15 at 03:00

1 Answers1

0

I don't think the thing you want to do is feasible. Not 100% at least. You could try to detect a single click inside the iFrame, but not in a specific target.

This answer (Detect Click into Iframe using JavaScript) cover the single click inside iFrame.

Hope it helps you!

Community
  • 1
  • 1
Inacio Schweller
  • 1,986
  • 12
  • 22