title: Print a cloned div in new window
body: <p>I am using the following code for printing a div in a new window:</p>
  
  <pre><code>$('#PrintNews').bind('click', function () {          
          var approot = '&lt;%=AppRoot %&gt;';
          var printContents = new $("#divToPrint").clone();
          var myWindow = window.open("", "popup", "width=800,height=600,scrollbars=yes,resizable=yes," +
               "toolbar=no,directories=no,location=no,menubar=no,status=no,left=250px,top=80px");
           var doc = myWindow.document;
  
           doc.open();
           $(printContents).find("#PrintNews").remove();
           $(printContents).find("#bottom").remove();
           doc.write("&lt;!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"&gt;");
           doc.write("&lt;html&gt;");
           doc.write("&lt;head&gt;");
           doc.write("&lt;link href='" + approot + "/Themes/print.css' rel='stylesheet' type='text/css' /&gt;");
           doc.write("&lt;link href='" + approot + "/Themes/secretaryPortal.css' rel='stylesheet' type='text/css' /&gt;");
           doc.write("&lt;/head&gt;");
           doc.write("&lt;body style='font: 11pt/1.2 Arial !important;'&gt;");
           doc.write("&lt;div class='story'&gt;");
           doc.write($(printContents).html());
           doc.write("&lt;/div&gt;");
           doc.write("&lt;/body&gt;");
           doc.write("&lt;/html&gt;");
           myWindow.document.close();
           myWindow.focus();
           myWindow.print();
           myWindow.close();           
          });
  
  });
  </code></pre>
  
  <p>It does open the print dialog But the page isn't with the original css.
  if i change the 4 last lines to:</p>
  
  <pre><code>         doc.document.close();
           doc.focus();
           doc.print();
           doc.close();  
  </code></pre>
  
  <p>It opens the page with the right CSS But the print dialog is not opened.
  i get an error saying <code>Uncaught TypeError: Cannot call method 'close' of undefined</code></p>
  
  <p>I have to open it in a new window cause i need to re-size to print dialog, i am aware of @media print </p>