首页 > 其他 > 详细

iframe加载顺序

时间:2020-11-04 09:57:48      阅读:70      评论:0      收藏:0      [点我收藏+]
var urls_to_load = ["http://url.com","http://url2.com","http://url3.com","http://url4.com"];
var i = 0;
function loadIframeAndcheckIfReady(){
    var current_url = urls_to_load[i];
    alert(i);
    frame = document.createElement(‘iframe‘);
    document.body.appendChild(frame);
    frame.setAttribute(‘src‘,current_url);
    var inter = window.setInterval(function() {
        if (frame.contentWindow.document.readyState === "complete") {
          window.clearInterval(inter);
          i++; //Now we have one url more...
          if(i < urls_to_load.length)loadIframeAndcheckIfReady(); //recursively call the function until i it‘s iqual to urls_to_load.length
        }
    }, 100);
}
loadIframeAndcheckIfReady(); //Start process

iframe加载顺序

原文:https://www.cnblogs.com/zany-hui/p/13924040.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!