Let me ask you a question. When iframe is introduced into react, I need to wait for all the html pages in the iframe to load before getting the height of the html. What I expect is to call the method in the parent react after obtaining the height in the child iframe. How to write
is currently written in this way, but the loaded iframe height is incorrect. It is suspected that onload is getting the height of the unfinished rendering of the child iframe
, so if you want to get the height in the child iframe, the method of adjusting the parent react page to set the height of the child iframe
<iframe
id="aa"
style={{width:"100%"}}
onLoad={() => {
const obj = ReactDOM.findDOMNode(this.refs.iframe);
console.log(obj,obj.contentDocument.body,obj.contentDocument.body.scrollWidth, obj.contentDocument.body.scrollHeight)
this.setState({
"iFrameHeight": obj.contentDocument.body.scrollHeight + "px"
});
}}
ref="iframe"
src="ink/ink.html"
width="100%"
height={this.state.iFrameHeight}
scrolling="no"
frameBorder="0"
>
</iframe>
Please do not hesitate to give advice to the great gods