I am trying to check wheater the URL of another domain exists or not from my domain('https://radiusofficefurniture.ie') using Javascript like :
var request = new XMLHttpRequest();
request.open('GET', 'https://www.mozilla.org', true);
request.onreadystatechange = function(){
if (request.readyState === 4){
if (request.status === 404) {
alert("Oh no, it does not exist!");
}
}
};
request.send();
But the issue of CORS policy occurred. The error is like this:
Access to XMLHttpRequest at 'https://www.mozilla.org/' from origin 'https://radiusofficefurniture.ie' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Kindly someone help me how can I check if the URL of other domains exists using javascript? Actually, I have to add an HTML tag to my site if the URL of other domains exists.