最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

圖片預(yù)載入第1/3頁(yè)

 更新時(shí)間:2006年10月03日 00:00:00   作者:  
特點(diǎn):
1.圖片預(yù)載入,載入后再顯示。意圖一次呈現(xiàn),不會(huì)讓一塊一塊下載破壞你的頁(yè)面,絕佳的用戶體驗(yàn),顛覆傳統(tǒng)的瀏覽器呈現(xiàn)圖片的處理方式(需要后續(xù)函數(shù)支持)。
2.不會(huì)因載入圖片造成腳本暫停假死,完全另一線程進(jìn)行。不影響主程序流程。
3.提供及時(shí)的反饋,包括兩方面的內(nèi)容:1.正在載入什么圖片 2.當(dāng)前的百分?jǐn)?shù)進(jìn)度。大大提高留住用戶眼球的概率,不會(huì)讓用戶因?yàn)榭嗟榷x開(kāi)。
4.容錯(cuò)支持,即使某個(gè)圖片沒(méi)有成功下載,也可以設(shè)置超時(shí)時(shí)間以便處理下一個(gè)圖片。
5.多變的參數(shù)類(lèi)型,盡最大可能方便使用。
復(fù)制代碼 代碼如下:

// save this as "image_loader.js"

//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-//
/*
  ImageLoader, Version 1.1, JavaScript 
  (c) 2006 Christian An <anchangsi@gmail.com>

  With copyright not modified, you can use this program freely. 
*/
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-//

function ImageLoader(className,Options){
    this._ImageLoadStack = null;
    this._currrentLoading = "";
    this._FinalRun = false;
    this.numLoaded = 0;
    this.ClassName = className;

    if(typeof(Options)=="undefined") Options = {};

    if(isNaN(Options.Timeout) || Options.Timeout < 0 ||  Options.Timeout >100000){
        this.EnableTimeout = false;
    }else {
        this.EnableTimeout = true;
        this.Timeout = Options.Timeout;
    }

    if(typeof(Options.func)=="undefined"){
        this.AfterFunction = null;
    }else{
        this.AfterFunction = Options.func;
    }

    if(typeof(Options.display)=="undefined"){
        this.disDiv = null;
    }else if(typeof(Options.display)=="string"){
        this.disDiv = document.getElementById(Options.display);
    }else if(typeof(Options.display)=="object"){
        this.disDiv = Options.display;
    }else{
        this.disDiv = null;
    }

    if(typeof(Options.process)=="undefined"){
        this.procDiv = null;
    }else if(typeof(Options.process)=="string"){
        this.procDiv = document.getElementById(Options.process);
    }else if(typeof(Options.process)=="object"){
        this.procDiv = Options.process;
    }else{
        this.procDiv = null;
    }

    
    if(typeof(document.imageArray)=="undefined") document.imageArray = new Array();

    this.Load = function(){
        var args = this.Load.arguments;
        if(args.length!=0){
            this._ImageLoadStack = new Array();
            for(i=0; i<args.length; i++){
                if(args[i].indexOf("#")!=0){
                    this._ImageLoadStack.push(args[i]);
                }
            }

        }else if(this._ImageLoadStack == null){
            this._runFinal();
        }
        this.numTotal = this._ImageLoadStack.length;
        this._LoadAImage();
    }

    this._LoadAImage = function(){
        if(this._ImageLoadStack.length!=0){
            var sURL = this._ImageLoadStack.shift();
            if(this.disDiv!=null) this.disDiv.innerHTML = sURL;
            _currrentLoading = sURL;

            
            var j = document.imageArray.length;
            document.imageArray[j] = document.createElement("IMG");
            document.imageArray[j].Owner = this;

            document.imageArray[j].onload = function(){
                this.Owner._LoadAImage();
                this.onload = null;
            }
            document.imageArray[j].onerror = function(){
                this.Owner._LoadAImage();
                this.onload = null;
            }

            if(this.EnableTimeout){
                window.setTimeout("if(_currrentLoading==\""+sURL+"\"){"+this.ClassName+"._LoadAImage()}",this.Timeout);
            }

            document.imageArray[j++].src = sURL;
                if(this.procDiv!=null){
                this.numLoaded++;
                var percentage = Math.floor(this.numLoaded * 100 / this.numTotal);
                this.procDiv.innerHTML = percentage;
            }

        }else{
            this._runFinal();
        }

    }
    this._runFinal = function(){
            if(this._FinalRun == false){
                this._FinalRun = true;

                if(typeof(this.AfterFunction)=="function"){
                    this.AfterFunction();
                }else if(typeof(this.AfterFunction)=="string"){
                    if (window.execScript){
                        window.execScript(this.AfterFunction);
                    }else{
                        window.eval(this.AfterFunction); 
                    }
                }
            }
    }
    this.setLoadImages = function(imageArray){
        if(typeof(imageArray)!="object") return;
        this._ImageLoadStack = imageArray;
    }

}

相關(guān)文章

  • layui中的tab控件點(diǎn)擊切換觸發(fā)事件

    layui中的tab控件點(diǎn)擊切換觸發(fā)事件

    這篇文章主要介紹了layui中的tab控件點(diǎn)擊切換觸發(fā)事件,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • javascript模擬實(shí)現(xiàn)計(jì)算器

    javascript模擬實(shí)現(xiàn)計(jì)算器

    這篇文章主要為大家詳細(xì)介紹了javascript模擬實(shí)現(xiàn)計(jì)算器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-04-04
  • JavaScript實(shí)現(xiàn)點(diǎn)擊按鈕就復(fù)制當(dāng)前網(wǎng)址

    JavaScript實(shí)現(xiàn)點(diǎn)擊按鈕就復(fù)制當(dāng)前網(wǎng)址

    在大量的網(wǎng)站都有這樣的功能,當(dāng)點(diǎn)擊一個(gè)按鈕的時(shí)候可以復(fù)制當(dāng)前頁(yè)面的地址,以此可以方便網(wǎng)站用戶對(duì)鏈接的存儲(chǔ),同時(shí)也便于網(wǎng)站的推廣,下面給大家分享具體實(shí)現(xiàn)代碼,對(duì)js實(shí)現(xiàn)點(diǎn)擊按鈕就復(fù)制的相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧
    2015-12-12
  • 一文了解你不知道的JavaScript生成器篇

    一文了解你不知道的JavaScript生成器篇

    ES6引入了一個(gè)新的函數(shù)類(lèi)型,發(fā)現(xiàn)它并不符合這種運(yùn)行到結(jié)束的特性。這類(lèi)新的函數(shù)被稱為生成器。生成器的出現(xiàn)是我們知道原來(lái)有時(shí)代碼并不會(huì)順利的運(yùn)行,可以通過(guò)暫停的方式進(jìn)行異步回調(diào),讓我們摒棄了此前的認(rèn)知。本文就來(lái)聊聊JavaScript中生成器的相關(guān)知識(shí)
    2022-11-11
  • JS文件上傳時(shí)如何使用MD5加密

    JS文件上傳時(shí)如何使用MD5加密

    這篇文章主要介紹了JS文件上傳時(shí)如何使用MD5加密,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • javascript 鼠標(biāo)事件總結(jié)

    javascript 鼠標(biāo)事件總結(jié)

    javascript的鼠標(biāo)事件是個(gè)比較龐大的家族。需要的朋友可以參考下。
    2009-12-12
  • js上下視差滾動(dòng)簡(jiǎn)單實(shí)現(xiàn)代碼

    js上下視差滾動(dòng)簡(jiǎn)單實(shí)現(xiàn)代碼

    這篇文章主要為大家詳細(xì)介紹了js上下視差滾動(dòng)的簡(jiǎn)單實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • javascript從定義到執(zhí)行 你不知道的那些事

    javascript從定義到執(zhí)行 你不知道的那些事

    這篇文章主要介紹了javascript從定義到執(zhí)行,你不知道的那些事,感興趣的小伙伴們可以參考一下
    2016-01-01
  • javaScript中push函數(shù)用法實(shí)例分析

    javaScript中push函數(shù)用法實(shí)例分析

    這篇文章主要介紹了javaScript中push函數(shù)用法,較為詳細(xì)的分析了javascript中push函數(shù)的功能、定義及使用技巧,需要的朋友可以參考下
    2015-06-06
  • js控制再次點(diǎn)擊按鈕之間的間隔時(shí)間可防止重復(fù)提交

    js控制再次點(diǎn)擊按鈕之間的間隔時(shí)間可防止重復(fù)提交

    使用js控制再次點(diǎn)擊按鈕之間的間隔時(shí)間可防止重復(fù)提交,需要的朋友可以參考下
    2014-08-08

最新評(píng)論

朔州市| 博兴县| 青田县| 乐业县| 怀集县| 鱼台县| 连城县| 广州市| 沅陵县| 磐安县| 武川县| 休宁县| 甘泉县| 广丰县| 阿坝| 治多县| 蓬莱市| 潼关县| 平塘县| 长丰县| 龙口市| 十堰市| 乐昌市| 自治县| 沙雅县| 合作市| 长泰县| 凤山县| 茶陵县| 梓潼县| 宾川县| 都昌县| 朝阳区| 吉安县| 新营市| 板桥市| 武宣县| 如皋市| 东阿县| 乌兰县| 新沂市|