iframe加载顺序


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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM