javascript - Find the HTTP status code of an image at `onload` event -
this question has answer here:
- how http status code of <img> tags 3 answers
suppose following code:
var img = new image(1, 1); img.onload = function() { console.log(arguments); }; img.src = 'some.place.com/some/image.jpg';
when image load, print arguments
, contains event
object, information request event, can't find anywhere status code.
the firing of onload
event doesn't distinguish between direct successful request or successful else redirect.
i need distinguish in code if request direct or redirect, can't find out how without http status code. there somewhere information available?
it's not possible http status of request made image element in javascript, you'd need use ajax loader in order access information this.
alternately, can use img.complete
:
htmlimageelement.complete returns boolean true if browser has fetched image, , in supported image type decoded without errors.1
Comments
Post a Comment