Skip to content

Instantly share code, notes, and snippets.

function hostReachable(location) {
if (!location) {
location = window.location.hostname + "/";
}
// Handle IE and more capable browsers
var xhr = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" );
var status;
// Open new request as a HEAD to the root hostname with a random param to bust the cache
xhr.open( "HEAD", "//" + location + "?rand=" + Math.floor((1 + Math.random()) * 0x10000), false );