Javascript Internet Connection Test not working
<p>I'm pretty much a novice at javascript and recently started learning it. Anyways, I have a strange problem. I am doing two checks in this code: a server connection check and an internet connectivity check. The server is actually physically connected to the client computer, and I check for connection every 3 seconds at startup so that the client will automatically launch once the server is up and running. Right now the client has a google-earth plugin, so I want to do an internet connection check so that I can launch the application without google-earth (and the related code) when there is no internet. However, the application seems to hang if I try to do both of these checks. It's driving me nuts because both of them work fine independently, but they fail when they are combined. </p>

<p>Also, in this code the image srcs both point to the same thing. I did this to make it easier for you guys to test it. Anyways, here's the code:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script type="text/javascript"&gt;
         document.getElementsByTagName('body')[0].innerHTML +=
         '&lt;img id="testImage" style="display: none;" ' + 
         'src = http://i.microsoft.com/about/shared/templates/components/mscomFooter/logo.png?' + Math.random() + '" ' + 
         'onerror="fail();" ' + 'onload="test2();"&gt;';
         function fail()
         {
            alert("fail")
         }

         function pass()
         {
            alert("pass")
         }

         function test2()
         {
             document.getElementsByTagName('body')[0].innerHTML +=
             '&lt;img id="testImage2" style="display: none;" ' + 
             'src = http://i.microsoft.com/about/shared/templates/components/mscomFooter/logo.png?' + Math.random() + '" ' + 
             'onerror="fail();" ' + 'onload="pass();"&gt;';
         }
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
