question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to know when iframe element was appended

See original GitHub issue

Hi,

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:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
iethemcommented, Nov 10, 2018

Is there a way to add a loading spinner for Facebook Embed?

0reactions
kevinqiu92commented, Dec 4, 2019

@Flave were you able to get this callback to work? I tried using both onReady and onParse and it doesn’t seem to be called.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found