Tag: 图像缓存

使用image.complete来查找图像是否缓存在chrome上?

我一直试图找出是否用js在浏览器上缓存了外部图像,这是我到目前为止的代码: function cached( url ) { $(“#imgx”).attr({“src”:url}); if(document.getElementById(“imgx”).complete) { return true; } else { if( document.getElementById(“imgx”).width > 0 ) return true; } return false; } $(document).ready(function(){ alert(cached(“http://sofzh.miximages.com/javascript/nav_logo80.png”)); }); 它在firefox上完美运行,但它总是在chrome上返回false。 有人知道如何使用chrome吗?