更新时间:2022-06-01 07:13:11
有几种方法可以做到这一点:
There is a few ways to do that:
使用ajax:
$.ajax({
url: "image.jpg",
type: "HEAD",
error: function () { alert("no image"); }
});
使用javascript图像对象:
Using the javascript image object:
var image = new Image();
image.src = "image.jpg";
if (image.width == 0) {
alert("no image");
}