How can I make the iframe adaptive content height? I searched many solutions on the Internet, but none of them worked. What should I do? Who has a good idea?
My example is very simple. a blank page references the homepage of Sohu. how does the framework adapt to the height?
I just want to give an example, not leeching. Thank you.
Reply to discussion (solution)
You have found a lot of answers and try again to change the iframe address to the same directory as the current page.
Also, you can write iframein 1.html, open 2.html, and write content in 2.html. At least, both files are yours and can be accessed by the same domain name.
Try the answer.
I don't want to write code for you. I just want to provide ideas. Because the page height of Sohu is unpredictable, you have to use js on the parent page to regularly check the content height of the subpage (Sohu) (simple, check the height of the document.) once the height changes, adjust the iframe height in js on the parent page, generally, according to the user's network latency, Sohu's page should be fully loaded in three or four seconds, and the height here will be basically constant.
I still did not solve the problem, and it is estimated that it is difficult to solve it.
1. js is required to modify the ifame height. I believe you have found the code.
2. js cannot operate cross-origin controls. You are not SOHU. Obviously, Sohu in iframe is cross-origin, so modification failed.
3. you can achieve your goal only by converting Sohu from cross-origin to non-Cross-origin.
4. php provides a way to obtain remote data (including web pages). you only need to apply the data flexibly.
It is very clear, that is,. I will learn how to get it.