javascript how to check if image exists
// create an XHR object
const xhr = new XMLHttpRequest();
// listen for `onload` event
xhr.onload = () => {
if (xhr.status == 200) {
console.log('Image exists.');
} else {
console.log('Image does not exist.');
}
};
// create a `HEAD` request
xhr.open('HEAD', '/img/bulb.svg');
// send request
xhr.send();
Also in JavaScript:
- javascript max array
- get a div text content and store in a variable js
- javascript remove duplicate strings from array
- javascript switch case regex
- js class private
- javascript element by class
- cannot find module @babel/compat-data/data/corejs3-shipped-proposals
- js script
- angular tilt
- node js post multipart/form-data
- how to check the extension of a file in javascript
- discord.js find word inside comment
- npm install save shortcut
- javascript wait 5 sec
- send message to user facebook game
- prevent default on enter press
- nodejs btoa
- sort data according to date in js
- for of and for in javascript
- oscar toledo chess javascript
- js add
- w3schools json
- angularjs find and update object in array
- c# parse json