Check if URL Exists

Question from Instagram

by Emanuel Borsoi

HTML

<h1>By <a href="//google.com/+ShahDanial" target="_blank">Shah Danial</a></h1>

JavaScript

var MrChecker = new XMLHttpRequest(),
            CheckThisUrl = "//www.gahhaoogle.com/ShahDanialerer";

        // Opens the file and specifies the method (get)
        // Asynchronous is true
        MrChecker.open('get', CheckThisUrl, true);

        //check each time the ready state changes
        //to see if the object is ready
        MrChecker.onreadystatechange = checkReadyState;

        function checkReadyState() {

            if (MrChecker.readyState === 4) {

                //check to see whether request for the file failed or succeeded
                if (MrChecker.status == 200) {

               
                alert(CheckThisUrl + ' page is exixts');

                }
                else {
                
                alert(CheckThisUrl + ' not exists');
                return;

                }

            }

        }
        MrChecker.send(null);