如下代码:

var url = "http://......../image.jpg";
var img = new Image();
img.src = url;
 
if(img.complete) {
    alert('该图片已经存在于缓存之中,不会再去重新下载');
}else{
    alert('图片不存在缓存之中');
    img.onload = function() {
        alert('图片下载成功!');
    }
}

shiyong

使用Image对象的complete属性来判断指定图片是否已经存在缓存之中,当complete属性为true是该图片则已经存在于缓存之中,否则反之。

相关文章:

  • 2021-08-26
  • 2022-12-23
  • 2022-02-02
  • 2021-07-08
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
相关资源
相似解决方案