Created
May 16, 2018 03:51
-
-
Save vrkansagara/8bfa6e85fae58e4cd158266777633e9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var url = 'https://vrkansagara.in' | |
| documentLinks = document.links | |
| var isHostIsUp = false; | |
| function doesConnectionExist() { | |
| var xhr = new XMLHttpRequest(); | |
| var host = url; | |
| xhr.open('HEAD', host, true); | |
| xhr.send(); | |
| xhr.addEventListener('readystatechange', processRequest, false); | |
| function processRequest(e) { | |
| console.log("e=>" + e); | |
| if (xhr.readyState == 4) { | |
| if (xhr.status >= 200 && xhr.status < 304) { | |
| isHostIsUp = true; | |
| } else { | |
| isHostIsUp = false | |
| } | |
| alert('==>' + isHostIsUp); | |
| } | |
| return isHostIsUp; | |
| } | |
| alert('asfasfa=>' + isHostIsUp); | |
| } | |
| if (doesConnectionExist()) { | |
| alert('connection exists!'); | |
| } else { | |
| alert('connection doesn\'t exist!'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment