title: Chrome print blank page
body: <p>I have an old javascript code to print images, if a user clicks on the thumbnail. It used to work just fine, but lately (only in Chrome!) there is a blank page in preview.</p>
  
  <p>Here is a demonstration in JsBin: <a href="http://jsbin.com/yehefuwaso/7" rel="noreferrer">http://jsbin.com/yehefuwaso/7</a>
  Click the printer icon. Now try it in Firefox; it will work as expected.</p>
  
  <p>Chrome: 41.0.2272.89 m</p>
  
  <p>Firefox: 30.0, 36.0.1</p>
  
  <pre><code>function newWindow(src){
  
    win = window.open("","","width=600,height=600");
      var doc = win.document;
      // init head
      var head = doc.getElementsByTagName("head")[0];
      // create title
      var title = doc.createElement("title");
      title.text = "Child Window";
      head.appendChild(title);
      // create script
      var code = "function printFunction() { window.focus(); window.print(); }";
      var script = doc.createElement("script");
      script.text = code;
      script.type = "text/javascript";
      head.appendChild(script);
      // init body
      var body = doc.body;
      //image
      doc.write('&lt;img src="'+src+'" width="300"&gt;');
  
      //chrome
      if (navigator.userAgent.toLowerCase().indexOf('chrome') &gt; -1) {
  
        win.printFunction();               
  
      } else {
          win.document.close();
          win.focus();
          win.print();
          win.close();
      }
  }
  </code></pre>