代码之家  ›  专栏  ›  技术社区  ›  RavenHursT

使用jQueryUI选项卡预加载AJAX内容的图像

  •  0
  • RavenHursT  · 技术社区  · 15 年前

    success: function(response){
        $(response).find('img').preload({
                onFinish: function(){
                        currentTabPanel.show();
                }
        });
    

    }

    2 回复  |  直到 15 年前
        1
  •  0
  •   zincorp    15 年前

    什么是回应?它代表什么?

    var imagePreloader = new Image();
    
    if(imgList.length != 0)
    {
       imagePreloader.load(function() {
          if(imgList.length != 0)
          {
             var img = imglist.pop();
             imagePreloader.src = img.imgSrc;
          }
          else
          {
             currentTabPanel.show();
          }
       });
    
       imagePreloader.src = imgList.pop().imgSrc;   
    }
    
        2
  •  0
  •   Alex Weber    15 年前

    这是一个肮脏的小脚本,我有时使用,但它的作品很好:

    var imgstopreload = new Array('file1.jpg', 'file2.jpg', 'etc.jpg');
    for (x in imgstopreload){
        (new Image).src = imgstopreload[x];
    }
    

    我不会对很多大图片这样做,因为在图片完成之前页面不会完成加载,但是如果你必须准备好它们,它可以工作。把它放在你的索引里:)