Set iframe to height of content for remote content

后端 未结 6 1955
时光取名叫无心
时光取名叫无心 2021-01-12 11:59

The question of how to make your iframe fit 100% of your content (using JavaScript) has been answered on the forum already... for iframes displaying content from the sam

6条回答
  •  忘掉有多难
    2021-01-12 12:29

    (My answer to a similar question)

    It is not possible to do this without some control over the page being iframed because of the browser's security model. If it was possible, that would be a security problem and would have to be fixed.

    Although letting the embedding site know the height of a third party webpage when embedded in the page seems harmless, this can leak information to the embedding site that the browser's user wants to keep private. For example, http://www.facebook.com/ renders differently depending on whether or not you are logged in, so if my website can work out the height of