0

I am using CasperJS to scrape some items, so I can't get on the page early enough to add load and error events on img tags. I would also prefer to not have to do a new XHR request for each image to determine it's validity.

Is there any way to select an image tag and determine if there is an image actually there or if it is not in which the alt text is displayed? JS only, after the page is fully loaded.

/ EDIT

Not sure why this was marked duplicate when I am specifically asking if there is a way to do this without another network request. The above question has answers that require additional network requests.

stewart715
  • 5,557
  • 11
  • 47
  • 80
  • http://stackoverflow.com/a/40440750/6746555 – Mahi Nov 17 '16 at 16:31
  • this is not a duplicate - all current answers to other questions require loading a new image and hence a another XHR request. My question specifically asks if there is a way to do this WITHOUT such a new request. – stewart715 Nov 17 '16 at 16:41
  • 1
    Changed dupe target to a better one. You can use the answer with naturalWidth / naturalHeight checks, which are [supported by all major browsers](http://caniuse.com/#search=naturalWidth). – Samuel Liew Nov 28 '16 at 03:25

0 Answers0