0

I want to provide my customers with a plugin which they can include in their website. Problem is that the content of the iframe changes everyday and has different heights. As I know the height of an iframe can be specified with css or a simple height tag, but then the height is fixed. I want to make the height change dynamically with the content, and this can be done with JavaScript, but how can I include a working JavaScript line inline the iframe code, so I don't confuse my customers?

Like

<iframe src="..." border="..." onload="..."></iframe>

EDIT I want to provide a single line of code, so that this code can be easily be implemented into the websites from my user.

John Brunner
  • 2,672
  • 9
  • 42
  • 79
  • try https://github.com/davidjbradshaw/iframe-resizer – Aamir Afridi May 13 '14 at 13:37
  • hm, i want to provide a single line of code which the users can implement in their website. you know what i mean? i can't tell them they have to implement a javascript plugin etc. – John Brunner May 13 '14 at 13:39

1 Answers1

0

What I've done in the past is to have the content of the frame update the title of it's document once it is loaded with it's content height then have the parent page after telling the frame to load a url poll for the title to equal a code specifying the height of the content then update the iframe size and stop polling. Unless things have changed with browser security the document title is the way I had found to get around the content of the frame being at a different domain than the parent page.

David
  • 3,171
  • 2
  • 22
  • 25
  • After doing a bit more reading it looks like the title is not available if the content of the frame is at a different domain. What could be done is to add the page height to the url and poll for that to exist. EG adding #height456 to the url to tell the parent that the height is 456px. – David May 13 '14 at 13:42