title: JavaScript - opening new window in print mode after document is ready
body: <p>I want to open a new window in print mode, after all images loaded(and the document is ready).
  Here is my code:</p>
  
  <pre><code>var win = window.open();
  //css ltr
  win.document.write('&lt;style&gt;body { direction: rtl; unicode-bidi: bidi-override; }&lt;/style&gt;');
  //insert img
  win.document.write('&lt;img src="assets/imgs/logo.png"&gt;' + '&lt;br&gt;');
  //insert txt
  win.document.write(pdf);
  win.document.write('&lt;br&gt;');
  win.document.write('&lt;img src="assets/imgs/buttomLogo.png"&gt;' + '&lt;br&gt;');
  win.print();
  win.close();
  </code></pre>
  
  <p>I had tried to use <code>onLoad()</code> but it print the document without the pictures:</p>
  
  <pre><code>win.onload = function () {
     win.print();
     win.close();                           
  }
  </code></pre>
  
  <p>How can I open the document in print mode with all the images?
  Fiddle - <a href="https://jsfiddle.net/7d2nfzbs/" rel="nofollow">printer</a>.</p>
  
  <p>Thanks.</p>