search

Home  >  Q&A  >  body text

javascript - Page nested iframe height setting problem

The page iframe is embedded in a third-party page.
How to set the height of this iframe to eliminate the scroll bar?
Because it is cross-domain, the document of the iframe cannot be obtained. Is there any other way?

世界只因有你世界只因有你2795 days ago808

reply all(3)I'll reply

  • PHPz

    PHPz2017-05-19 10:28:37

    Unless you can add code in a third-party iframe, it won’t work.

    If you can add code, it will inform the parent page height through various cross-domain iframe communication methods.

    reply
    0
  • 迷茫

    迷茫2017-05-19 10:28:37

     1. document.getElementById('ifr').contentDocument; 
     2. document.getElementById('ifr').contentWindow.document; 
     3. window.frames[0].document; 

    Some information on the Internet states that contentWindow is only valid for IE, and contentDocument is only valid for non-IE browsers. However, after my testing, these two methods are valid for current mainstream browsers (ie, firefox, chrome, safari, opera). )

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-19 10:28:37

    /a/11...

    See if this article helps

    reply
    0
  • Cancelreply