多個iframe 載入

來源:互聯網
上載者:User

遍曆iframe,然後載入相應的iframe時,iframe不會是按順序載入,按我的測試,應該是隨機或者並列,

for(var i=0;i<iframe.length;i++){$("#iframe"+i).load(function(){i++;alert(i);})}

最終結果:所有的i的長度會是最大值

但是我一定要確定一個iframe都載入完了才能繼續執行下一個iframe,所以,

// genaral iframe and log out all sc function generateFrameAndCloseSCs(){//it the time goes 10s can't logout,it will enter the redirectLogout()setTimeout("redirectLogout();",8000);$.ajax({url:"<%=Config.getHomeURL()%>/PlugInManageAction.do?operation=getAllDyncMenu",type:"POST",dataType:"json",async:false,success:function(result){var SCURLList=result.SC_urlList;if(SCURLList.length!=0){var i=0;loadIframe(i,SCURLList);//travel load frame.}else{//if it didn't have dync menu ,it will direct into  login(); redirectLogout();}}})}
function loadIframe(i,SCURLList){var iframe = document.createElement("iframe");iframe.src = SCURLList[i];iframe.style.display='none';var length=SCURLList.length;if(i==length){redirectLogout();}else{//核心代碼if (iframe.attachEvent){//IEiframe.attachEvent("onload", function(){i++;loadIframe(i,SCURLList);});} else {//not IEiframe.onload = function(){i++;loadIframe(i,SCURLList);};}document.body.appendChild(iframe); } }

 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.