Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js check link if exists

//checking link
function urlExists(url, callback) {
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
            callback(xhr.status < 400);
        }
    };
    xhr.open('HEAD', url);
    xhr.send();
}


// run function
function check_link(url) {
    urlExists(url, function (exists) {
        if (exists) {
            console.log('"%s" exists?', url, exists);
        }
    });
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: is material ui not working with react 18 
Javascript :: Sending an Ajax request before form submit 
Javascript :: Html2Canvas screenshot and download 
Javascript :: youtube video regex 
Javascript :: discord delete messag 
Javascript :: javascript check if variable is number 
Javascript :: prettier/prettier in react 
Javascript :: removeclass multiple 
Javascript :: touppercase 
Javascript :: a function that calls itself js 
Javascript :: javascript remove property from object 
Javascript :: jquery add style background-image 
Javascript :: jest expect error type 
Javascript :: pyspark json multiline 
Javascript :: javascript round to 1 decimal 
Javascript :: next js Pages with Dynamic Routes 
Javascript :: sort array of objects by string property value 
Javascript :: nodejs mysql insert object query 
Javascript :: contains whitespace js function 
Javascript :: next js getserversideprops 
Javascript :: select checked checkboxes javascript 
Javascript :: setimmediate vs settimeout 
Javascript :: jquery div element find and remove 
Javascript :: render tab screen when goBack function is called of other screen 
Javascript :: react native text ellipsis 
Javascript :: disable submit button if input is empty 
Javascript :: how to append the dropdown values by jquery each function 
Javascript :: js onchange input value event listene 
Javascript :: string contains javascript 
Javascript :: bootstrap modal clear all fields 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =