showing results for - "js check if image url exists"
Arsène
05 Apr 2017
1function checkImage(url) {
2  var request = new XMLHttpRequest();
3  request.open("GET", url, true);
4  request.send();
5  request.onload = function() {
6    status = request.status;
7    if (request.status == 200) //if(statusText == OK)
8    {
9      console.log("image exists");
10    } else {
11      console.log("image doesn't exist");
12    }
13  }
14}
15checkImage("https://picsum.photos/200/300");
Lilas
31 Apr 2018
1// create an XHR object
2const xhr = new XMLHttpRequest();
3
4// listen for `onload` event
5xhr.onload = () => {
6    if (xhr.status == 200) {
7        console.log('Image exists.');
8    } else {
9        console.log('Image does not exist.');
10    }
11};
12
13// create a `HEAD` request
14xhr.open('HEAD', '/img/bulb.svg');
15
16// send request
17xhr.send();
18
Vicente
06 Sep 2016
1function checkImage(url) {
2  var request = new XMLHttpRequest();
3  request.open("GET", url, true);
4  request.send();
5  request.onload = function() {
6    status = request.status;
7    if (request.status == 200) //if(statusText == OK)
8    {
9      console.log("image exists");
10    } else {
11      console.log("image doesn't exist");
12    }
13  }
14}
15checkImage("https://apitest.cargoxrate.com/cache/upload/39908016179913740685.jpg?https://picsum.photos/200/300");
queries leading to this page
how to check if img src existscheck image exist in javascriptway to check if image exists javascriptjavascript check if url image existscheck if image contain source exists javascriptjavascript check image exists urljavascript verify if is image from urlhow to check if image exists with given url javascriptjavascript image existsjs check if string is image urlcheck if something is an image url javascriptcheck image exists or not on server using javascriptcheck image path exists javascriptjs detect if image exists without errorif else when img exist jshow to check if an image exists in jscheck if url is image javascriptcheck if image exists at url javascriptjavascript check if image exists in tag check if an image exists javascriptjavascript check if image existsjs check if image exists on serverjs check if image file is foundcheck if image exists javascriptfunction to check if an image existsjs check if image url has imagecheck if an url is an image jshow to detect if image url existsangular check if image src existscheck if image is present on a path javascriptjs detect if image existshtml check if image url existshow to check if an image is available or not javascriptjavascript check if url is imagejs check image existsjs check if image exists on the serverhow to check if image exististr in javascriptjavascript check image exists in urljavascript is image url existsvalidate i url for image exists javascriptnode check if image existscheck if image existes javasceipthow to check if image 28url 29 exists in javascriptcheck if url is image jsjavascript check image exist on serverhow to check if the image file exists in jshow to get if an image exists with javascriptchecking the images whether it is present in folder in jscheck image exists javascriptcheck if image exists jscheck if url is imagecheck if a url gives image exists javascriptnode js check if image existsjavascript check image src existsjavascript check if image exists in folderjavascript check if the image address exist in the filejs check if image is brokenhow to check if a file is an image in js reactreturn image only if exist jscheck if image exists in url javascriptcheck exiss img jsidentify if image does not exist javascriptcheck if url if of an imagejavascript check if image from url existsjs check if image exists in directoryjs check if url contains an imagejavascript check if image exists quicklyif image exists javascriptif images exists in javascriptjavascriptcheck if image existsjavascript validate image urljavascript check if an image exists onlinejs how to check if image existsjavascript check if image src existsjavascript how to check if image existsjs check if url is imagejavascript test if image url existscheck if image source exists javascriptcheck if image ext jscheck whether image exists javascriptcheck image exist javascriptjs test if image errorcheck if url image source exists javascripthow to check image exist or not in javascriptif image does not exist javascriptcheck if image exist javascriptjavascript if image existjavascript check if image source existscheck if remote image exist javascriptjavascript check if img src existscheck if image src exists javascriptjs check if image existsimage file exist check jscheck if image exists by url jscheck if image exist on urljs check if picture in picture existscheck if img src existscheck image is exist javascriptjavascript check if image url existjs check if image url existscheck if image exists nodejscheck if image url exists javascriptcheck if a link for image exist jshow to check if image exists in a link using javascriptcheck if image url found by javascriptjavascript check if image exists elsehow do i know when a file is not an image in jsjavascript does image existjavascript check if image url is validjavascript test if image existscheck if image exists in path jsjavascript check if image file existsjavascript check if image exissthow to check if an image exists in js and return that urlvalidate image exist javascripthow to check if image exists with given url node jsjavascript test image existscheck if url contains image jshow to check image is exist or not in jscheck image exists in jscheck if a url has image jsjavascript check if image exists at urlcheck to see if image exists in folder javascriptexists img jshow verify if url image exists in jscheck if image url is valid javascriptjavascript check url image existsjavascript check if image url existsjs if image on file path existsfastest way if img exists javascripthow to check image exist in folder in javascriptcheck if image exist on computer with jshow to check if an image exist in our folder jscheck exist img srcjavascript check image url existscheck image exist or not in javascriptcheck image exists or not in javascriptjs check if image url exists