davidjbradshaw / iframe-resizer

Keep iFrames sized to their content.
https://iframe-resizer.com
Other
6.65k stars 981 forks source link

Library removes height:auto inline style from html and body elements #1159

Closed DanielStout5 closed 10 months ago

DanielStout5 commented 1 year ago

Describe the bug The site being embedded in the iframe has a height:100% CSS rule applied to HTML and Body. We are overriding it via an inline style, but that's getting removed by this function:

function stopInfiniteResizingOfIFrame() {
    document.documentElement.style.height = ''
    document.body.style.height = ''
    log('HTML & body height set to "auto"')
  }

To Reproduce

  1. Create a page with
  2. Embed it in an iframe and add the iframe-resizer library
  3. Observe that height:auto gets removed

Expected behavior The inline style should not be removed if its value is auto

davidjbradshaw commented 1 year ago

Yeah if you set those properties it can cause havoc with keeping tabs on the size of the content in the iFrame. This code is their to protect you from that.