title: Load image using Javascript?
body: <p>Here's the current code of my HTML page:</p>
  
  <pre><code>&lt;!doctype html&gt;
  
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Example&lt;/title&gt;
  &lt;meta name="robots" content="noindex, nofollow"&gt;
  &lt;meta http-equiv="refresh" content="3;URL='http://google.com'" /&gt; 
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;script&gt;
  var image = document.images[0];
  var downloadingImage = new Image();
  downloadingImage.onload = function(){
      image.src = this.src;   
  };
  downloadingImage.src = "http://example.com/pixel";
  &lt;/script&gt;
  
  &lt;script&gt;
  window.location = "http://google.com";
  &lt;/script&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>This part of the code should be using Javascript to load an image:</p>
  
  <pre><code>var image = document.images[0];
  var downloadingImage = new Image();
  downloadingImage.onload = function(){
      image.src = this.src;   
  };
  downloadingImage.src = "http://example.com/pixel";
  </code></pre>
  
  <p>This is being done to verify is a user has javascript enabled or not. We direct visitors to specific advertisers and certain ones require that Javascript be enabled. The pixel that's being loaded is so we can track fraudulent traffic from third-party vendors that try to send millions of bot hits using stuff like curl.</p>
  
  <p>The amount of users with javascript enabled is slightly lower than I expected and I'm not trying to debate the amount.  But does anyone see anything wrong with this code?</p>
  
  <p>It's my understanding that javascript loads in order, so the image should be loaded in a browser before the user is redirected, correct?  And do you see anything wrong in the code that I guess would cause it to not load in certain browsers?</p>