title: Print image with Javascript
body: <p>I want to print image with javascript.
  So I used this code to open image in new window and print:</p>
  
  <pre><code>win = window.open(img.src,"_blank");
  win.onload = function() { win.print(); }
  </code></pre>
  
  <p>This works fine with the default image file:</p>
  
  <pre><code>&lt;img id="image1" src="myimage.jpg"&gt;
  </code></pre>
  
  <p>But when i replace the default image with image data read from disk:</p>
  
  <pre><code>var fileElem = document.getElementById("fileElem").files[0];
  var reader = new FileReader();
  reader.onload = function(event) {
     img.src = event.target.result;
  };
  reader.readAsDataURL(fileElem); 
  </code></pre>
  
  <p>And then open new window &amp; print - the image apears fine in the new window, but no print operation is done.
  How to make the win.print() to work?</p>