JScript判断图片是否存在

//判断图片是否存在
function checkImgExists(imgurl) {
    var ImgObj = new Image(); //判断图片是否存在
    ImgObj.src = imgurl;
    //存在图片
    if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {
        alert("true");
         return true;
    } else {
        alert("false");  
         return false;
     }

 
}
posted @ 2023-09-13 14:48  小风风的博客  阅读(6)  评论(0编辑  收藏  举报