Check LAN connection by javascript -


i have deployed web application in machine, connected other client machine in lan. while client using web app through browser need check whether lan connection exist each request javascript.

i have googled lot this, content regarding internet connection , not regarding lan connection. in advance.

try 1 : works me :)

function hostreachable() {    // handle ie , more capable browsers   var xhr = new ( window.activexobject || xmlhttprequest )( "microsoft.xmlhttp" );   var status;    // open new request head root hostname random param bust cache   xhr.open( "head", "//" + window.location.hostname + "/?rand=" + math.floor((1 + math.random()) * 0x10000), false );    // issue request , handle response   try {     xhr.send();     return ( xhr.status >= 200 && xhr.status < 300 || xhr.status === 304 );   } catch (error) {     return false;   }  } 

reference


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -