<p>This seems more like a jquery issue then a craft issue. You might look into jquery's <code>load</code> method. Doing a quick google search I came up with <a href="https://stackoverflow.com/questions/205087/jquery-ready-in-a-dynamically-inserted-iframe">this possible solution</a>, which you would need to adapt. </p>

<pre><code>function callIframe(url, callback) {
    $(document.body).append('&lt;iframe id="myId" ...&gt;');
    $('iframe#myId').attr('src', url);

    $('iframe#myId').load(function() {
        callback(this);
    });
}
</code></pre>

CC BY-SA 3.0
2015-01-21T19:46:40.683Z
2015-01-21T19:46:40.683Z
2017-05-23T12:38:53.957Z
Douglas McDonald
<p>I have a couple of youtube iframes loaded into a channel entry. I also have a script running that resizes those iframes. It appears the script fires on window load but it appears that it fires before the iframes load in from craft. Is there any quick fix to this issue and if so how do I fix it?</p>

<javascript><jquery>
Javascript loads before iframes
# Javascript loads before iframes

(Asked by: username_0 on 2015-01-21)

I have a couple of youtube iframes loaded into a channel entry. I also have a script running that resizes those iframes. It appears the script fires on window load but it appears that it fires before the iframes load in from craft. Is there any quick fix to this issue and if so how do I fix it?

**Tags:** javascript, jquery


---

## 1 answers

### Answer by username_1 on 2015-01-21. Score: 3

This seems more like a jquery issue then a craft issue. You might look into jquery's load method. Doing a quick google search I came up with this possible solution, which you would need to adapt. 
function callIframe(url, callback) {
    $(document.body).append('');
    $('iframe#myId').attr('src', url);

    $('iframe#myId').load(function() {
        callback(this);
    });
}


---

