mbuff24
mbuff24

Reputation: 425

Javascript load event on injected html

If I inject html (iframe containing a video) through javascript is there an event/function that can be used to see if the injected HTML is finished loading?

I tried including javascript at the bottom of the injected content but that is not being executed.

Also I do not plan on using jquery.

Upvotes: 2

Views: 630

Answers (2)

Adam Rackis
Adam Rackis

Reputation: 83366

After you inject the html, you could subscribe to the iframe's onload event:

document.getElementById("iframeId").onload = function(){
    alert("Loaded!");
};

Upvotes: 1

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114417

If the content is from another domain, all you can capture is the onload event for the iframe itself. That doesn't tell you the content has rendered, just that it has loaded.

Upvotes: 1

Related Questions