title: navigator.onLine is not working in Firefox, Safari, Opera? Works in IE, Chrome?
body: <p>In my chat application I need give a intimation to the user, when the Internet connection is inactive?</p>
  <p>So I used the JavaScript <strong>navigator.onLine</strong>, but it works in IE and Chrome. Not in other browsers.</p>
  <p>My JavaScript will be:</p>
  <pre><code>function pingAction(){
      if (navigator.onLine) {
          setTime();
          try
          {
              xmlhttp.onreadystatechange=function()
              {
                  if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
                  {
                      var checkMsg = xmlhttp.responseText.toString();
  
                  
                      if(checkMsg != &quot;null&quot; &amp;&amp; checkMsg.length != 0  &amp;&amp; checkMsg != null){
  
                          var stringToArray = new Array;
                          stringToArray = checkMsg.split(&quot;&lt;//br//&gt;&quot;);
                          var len = stringToArray.length;
                          for(var i=0;i&lt;len-1;i++){
                              //alert(stringToArray[i]);
                              getText(stringToArray[i]);
  
                          }
  
                      }
                  }
              };
  
              xmlhttp.open(&quot;POST&quot;,&quot;PingAction&quot;,true);
              xmlhttp.setRequestHeader(&quot;Content-type&quot;,&quot;application/x-www-form-urlencoded&quot;);
              xmlhttp.setRequestHeader(&quot;charset&quot;,&quot;UTF-8&quot;);
              xmlhttp.send(&quot;userId=&quot;+encodeURIComponent(userId)+&quot;&amp;secureKey=&quot;+encodeURIComponent(secureKey)+&quot;&amp;sid=&quot;+Math.random());
          }
          catch(err)
          {
              alert(err.description);
          }
      }else{
          //alert(&quot;offLine   ...&quot;);
          document.getElementById(&quot;serverMsg&quot;).style.backgroundColor=&quot;yellow&quot;;
          document.getElementById(&quot;serverMsg&quot;).innerHTML =&quot;Your Network connection is failed !&quot;;
          document.getElementById(&quot;serverMsg&quot;).style.display=&quot;inline&quot;;
      }
  }
  </code></pre>
  <p>Hope you people will give a good solution.</p>