0
votes

I am looking for a way to resize an iframe in the y-axis that the content fits in.

The problem is, all solutions that I can find on the web are not working anymore because of the modern CORS and Same Origin rules of the browsers.

But there must be a way to do it, as ebay is still able to fit the iframes according to the height of the content. First, I thought this might be server-sided, but disabling JS showed me the initial height of the iframe is something around 10k px.

Which property of the child-frame are they using that is available for the parent frame?

1
Show us how to see that on eBay.Buzinas
Go on some auction on ebay (e.g. ebay.de/itm/…) and have a look at the description, disable javascript and look again.Tobi
The only iframe tags I see in that link are the advertisement ones (google ads, doubleclick). Not even one other iframe than those.Buzinas
Very very strange. Now, also on my browser the iframe is gone...Tobi

1 Answers

0
votes

Keep in mind that essentially an iframe has no knowledge of, or interaction with, its parent and therefore cannot know the size of its parent container.

There are ways of interacting with the parent if the iframe src is from the same domain as the parent but, as you say, this will not work cross-domain.

I looked into this before and really the only way I could find to do it was with a library: https://github.com/davidjbradshaw/iframe-resizer (which works cross-domain) . The good news is that this is a good library and works well.