我试图使用 javascript 测试某些文件是否存在。(不想使用 Ajax)。想要使用catch尝试处理ERR_FILE_NOT_FOUND错误。我试过
try{
img.attr('src', url)
}catch(err){
console.log("file"+ url + " doesn't exist");
}
Run Code Online (Sandbox Code Playgroud)
但它没有捕获错误。如何捕获 ERR_FILE_NOT_FOUND 错误?