Cross-cutting (native) javascript, I want to check if the image exists. I found this script:
function imageExists(image_url){ var http = new XMLHttpRequest(); http.open('HEAD', image_url, false); http.send(); return http.status != 404; }
from this question . However, every time I run this, it gives me a HEAD error message whenever it does not find the image (in the console). Can I get rid of this error whenever it does not find something?
The onload / onerror solution in the comments on a related question also gives me the same problem with error messages.
source share