0

There's a div including a picture set to fit the screen height.

It works except being in an iframe, the height becomes the content height which equals to the scroll height but not the screen height.

Is there any method to let the div in the iframe grabs the real screen height or its parents' screen height?

Or can I write a script to catch the real screen height and fake it as the screen height to be caught by the elements in the iframe without doing any modification in the iframe?

jimh
  • 1
  • 1
  • To have a successful question here you really need to show the work you've done and where you're stuck. That being said, you might be interested in this: https://github.com/davidjbradshaw/iframe-resizer – Matt Jul 25 '18 at 03:11
  • Please include your code. – leogoesger Jul 25 '18 at 03:12
  • actually, my question is like this https://stackoverflow.com/questions/44506160/background-image-size-within-an-iframe-is-stretched – jimh Jul 26 '18 at 07:27
  • Background image size within an iframe is stretched. – jimh Jul 26 '18 at 07:27

1 Answers1

0

You can run a script in the parent container that calls a function in the iframe and sends a reference to itself with the call. With this reference the iframe can control the parent and e.g. read properties like window.height etc.

This can only be done if both sites (parent and child) are on the same domain. Even if you run the scripts from your disc without a webserver it might not work!

See Invoking JavaScript code in an iframe from the parent page for more details.

Thieri
  • 203
  • 1
  • 10