It is not possible to get the status code directly in JavaScript without XMLHttpRequest. As already mentioned, this is usually only a single-user domain, although there are two possible approaches to the cross-domain approach (not requiring a proxy server), which I know of:
On the other hand, if all that cares is an image that can be loaded (it may not be quite 200!), This can be found using the Image element and the onload , if the onload does not fire for a certain period of time , we can conclude that a timeout or failure was requested (4xx / 5xx). However, this will return a false positive result in the case of 302, etc.
Just make sure that the browser is really trying to download the image: some of the smarter ones will not download hidden images, or, as I already heard.
Happy coding.
user166390
source share