title: Javascript: image object -> HTML image element
body: <p>The code preloads an image into an image object and then (supposed to) set it to the image element src on HTML:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;script language="javascript"&gt;
          window.onload = function () {
              var oImage = new Image();
              oImage.onload = function () {
                  document.getElementById('myImage').src = oImage;
                  alert('done');
              };
              oImage.src = 'image1.jpg';
          }
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;img id="myImage" src="" /&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Why it doesn't work?</p>