JavaScript does not allow you to do cross-domain call but you can test if a site is up or down using this script:
function checkServerStatus( url ) { var script = document.body.appendChild(document.createElement("script")); script.onload = function() { alert( url + " is online"); }; script.onerror = function() { alert( url + " is offline"); }; script.src = url; } checkServerStatus( "http://google.com" ); checkServerStatus( "http://thisdomainsurelynotexists.me" );
I found this code at https://petermolnar.eu/linux-tech-coding/test-site-javascript
Follow Us