How to know when iframe element was appended
See original GitHub issueHi,
I’m trying to get the height of a rendered Facebook Post. In order to do that I want to attach an iframe.onload
event listener. It seems though as if the iframe is not appended immediately. Inside componentDidMount it isn’t possible yet to grab the iframe.
componentDidMount() {
// no iframe is being found here
$(this.root).find('iframe').on('load', function() {
console.log(this.root.clientHeight);
}.bind(this));
}
render() {
return (
<div ref={(root) => this.root = root} className="feed__item">
<FacebookProvider appId="1754125368233773">
<EmbeddedPost href={this.props.url} width="400" />
</FacebookProvider>
</div>
);
}
Is there a way to actually achieve this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to check if iframe is loaded or it has a content?
Try this. <script> function checkIframeLoaded() { // Get a handle to the iframe element var iframe = document.getElementById('i_frame'); var iframeDoc ...
Read more ><iframe>: The Inline Frame element - HTML - MDN Web Docs
The <iframe> HTML element represents a nested browsing context, embedding another HTML page into the current one.
Read more >Inserting and Populating an iframe Element
First, we are going to append an iframe to the end of the body element, and then we will put a dynamically generated...
Read more >.contents() | jQuery API Documentation
Determine whether or not the list has any callbacks attached. If a callback is provided as an argument, determine whether it is in...
Read more >How To Get an Element in an iframe - W3Schools
Click the button to hide the first H1 element in the iframe (another document). Hide H1 Element. Get Element in Iframe. Get the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there a way to add a loading spinner for Facebook Embed?
@Flave were you able to get this callback to work? I tried using both
onReady
andonParse
and it doesn’t seem to be called.