解决方法
试试这个.答案发现于
link
// The "callback" argument is called with either true or false // depending on whether the image at "url" exists or not. function imageExists(url,callback) { var img = new Image(); img.onload = function() { callback(true); }; img.onerror = function() { callback(false); }; img.src = url; } // Sample usage var imageUrl = 'http://www.google.com/images/srpr/nav_logo14.png'; imageExists(imageUrl,function(exists) { console.log('RESULT: url=' + imageUrl + ',exists=' + exists); });