0

for domload performance im reaching to load my 2 ytb iframes through a loop after Onload, it works for the first one, console is not throwing errors, target divs are the 2 <div class="ytb-holder-image"></div>, am i missing something?

var srcs= new Array();
    srcs[0]= "fhIHMDpbQDI";
    srcs[1]= "oMRZp7cp79g";

function createIframe(){

    for (var j = 0; j < 1; j++)
    {
      var i = document.createElement("iframe");
          i.src = 'http://www.youtube.com/embed/'+srcs[j];
          i.width = "853xp";
          i.height = "480px";
          document.getElementsByClassName("ytb-holder-image")[j].appendChild(i);
        };

    }

for documentation, if someone wants to load his content in a similar way here are the conditions for IE:

if (window.addEventListener)
window.addEventListener("load", createIframe, false);
else if (window.attachEvent)
window.attachEvent("onload", createIframe);
else window.onload = createIframe;
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.