title: onload callback on image not called in ie8
body: <p>I'm trying to preload image and set the height and width to a container.</p>
  
  <p>The problem seems to be with caching in ie8 since it fails to load on subsequent refreshes.</p>
  
  <p>I've looked up and tried multiple solutions but seems nothing is working, at least not consistently.</p>
  
  <p>current Javascript:</p>
  
  <pre><code>    img = new Image();
      img.src = '/images/site/image.jpg';
      img.onload=function(){
          var width = img.width + 'px';
          var height = img.height + 'px';
  
          $('#container').css({'width':width,
                            'height':height
          });
      };
  </code></pre>
  
  <p>Any suggestions are appreciated, thanks.</p>