国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

javascript順序加載圖片的方法

2019-11-20 12:01:42
字體:
來源:轉載
供稿:網友

本文實例講述了javascript順序加載圖片的方法。分享給大家供大家參考。具體如下:

javascript監聽一個圖片是否加載完畢 如果加載完成再加載下一張,不是一次性從服務器加載 減少服務器壓力,
可用到的地方:比如制作類似google地圖的應用,可以使小圖一張一張的加載

function Load_pic(arr){ this.loop_f=function(i,o_file,len,f,obj){   if(i<len-1){     i=i+1;     f(i,o_file,len,obj);     }  };  this.creat_pic=function(i,o_file,len,obj){    var f=arguments.callee,    doc=document,    image = doc.createElement("img");      image.src =o_file[i];    i<len?doc.getElementsByTagName("body")[0].appendChild(image):'';    if(navigator.userAgent.indexOf("MSIE")>0){         if($.browser.version==6.0 || $.browser.version==9.0){        //IE9和IE6一樣 微軟真是怪異          image.onreadystatechange = function () {             if (image.readyState == "complete"){               obj.loop_f(i,o_file,len,f,obj);            }           };         }else{           ie7imagetime = window.setInterval(function(){             var rs = image.readyState;             if(rs=="complete"){               window.clearInterval(ie7imagetime);               obj.loop_f(i,o_file,len,f,obj);            }else{               return;             }           },200);         }       }else{         image.onload = function () {           if (image.complete == true){           obj.loop_f(i,o_file,len,f,obj);          }         };     }  };    if(arr.constructor===Array){   var len=arr.length,      i=0;   i<len?this.creat_pic(i,arr,len,this):'';  }; }//調用方法new Load_pic(['http://gomap.dashilan.cn/jquery-mobile/map/cq/1/img_1/0_0.gif','http://gomap.dashilan.cn/jquery-mobile/map/cq/1/img_1/0_1.gif','http://gomap.dashilan.cn/jquery-mobile/map/cq/1/img_1/0_2.gif','http://gomap.dashilan.cn/jquery-mobile/map/cq/1/img_1/0_3.gif','http://gomap.dashilan.cn/jquery-mobile/map/cq/1/img_1/1_0.gif','http://gomap.dashilan.cn/jquery-mobile/map/cq/1/img_1/1_1.gif','http://gomap.dashilan.cn/jquery-mobile/map/cq/1/img_1/1_2.gif','http://gomap.dashilan.cn/jquery-mobile/map/cq/1/img_1/1_3.gif']);//注意要調用jquery 用于判斷瀏覽器

希望本文所述對大家的javascript程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永济市| 呼伦贝尔市| 东方市| 炎陵县| 马尔康县| 高台县| 绿春县| 桂阳县| 遂川县| 海林市| 烟台市| 新晃| 锡林浩特市| 聊城市| 建水县| 文安县| 云龙县| 教育| 蕉岭县| 陕西省| 荃湾区| 西城区| 江达县| 临漳县| 贵州省| 保德县| 河东区| 大名县| 鄂托克前旗| 梁平县| 县级市| 墨玉县| 清镇市| 霍邱县| 太康县| 晋江市| 大渡口区| 唐山市| 阜城县| 积石山| 达尔|