banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

[HTML] Make the iframe adapt its width and height according to the content of the iframe

A strange requirement, the center of an html page A needs to use an iframe to open another page B. The content of page B can be long or short, and it is required that the iframe used to display the content of page B adjusts its height according to the actual display height of page B. At the same time, the code of page A cannot be modified.

Solution: Using iframe, you can directly use parent.parent.document to control the content of the parent page's document, but you need to pay attention to the timing of adaptive adjustment, which needs to be done after page B is fully loaded. Implementation code, tested effective in IE: A page (parent.html), code unchanged

B page (child.htm)

111
222
333
444
555
666
777
888
999
000

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.