title: Print using a button from window.open
body: <p>I have the following button which opens a new window </p>
  
  <pre><code>&lt;a href="javascript:void(0);" class="btn btn-lg green" onclick="PrintElem('#sample_editable_1', 'Fault Recording')"&gt;&lt;i class="fa fa-file-text-o" aria-hidden="true" style="padding-right: 5px;"&gt;&lt;/i&gt;Run Report&lt;/a&gt;
  </code></pre>
  
  <p>In my js file, I have this function which creates the window:-</p>
  
  <pre><code>function PrintElem(elem, h1)
  {
        Popup($(elem).html(), h1);
  }
  
  function Popup(data, h1) 
  {
      var mywindow = window.open('', 'my div', 'height=768,width=1024');
      mywindow.document.write('&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;');
      mywindow.document.write('&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;');
      mywindow.document.write('&lt;html&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;');
      mywindow.document.write('&lt;link rel="stylesheet" href="'+base_url+'/css/print1.css'+'" type="text/css" /&gt;');
      mywindow.document.write('&lt;link rel="stylesheet" href="'+base_url+'/assets/global/plugins/font-awesome/css/font-awesome.min.css'+'" type="text/css" /&gt;');
      mywindow.document.write('&lt;script src="'+base_url+'js/custom.js'+'" type="text/javascript"&gt;&lt;/script&gt;');
      mywindow.document.write('&lt;/head&gt;&lt;body&gt;');
      mywindow.document.write('&lt;h1 class="pdfTitleDv" &gt;'+h1+'&lt;/h1&gt;');
      mywindow.document.write($('#window_print').html());
      mywindow.document.write('&lt;table border="0" cellpadding="0" cellspacing="0" class="table table-bordered table-striped table-condensed flip-content table-hover datatableDv " id="sample_editable_1"&gt;');
      mywindow.document.write(data);
      mywindow.document.write('&lt;/table&gt;');
      mywindow.document.write('&lt;/body&gt;&lt;/html&gt;');
      mywindow.document.close();
      mywindow.focus();
      return true;
  }
  
  function print(){
      window.print();
  }
  </code></pre>
  
  <p>I have the following button in the new window which I created there I have a button I want to print the table which is in the window. please see the HTML below:-</p>
  
  <pre><code>&lt;div class="btn-group pull-right btm-btn"&gt;
     &lt;a href="javascript:void(0);" class="btn btn-lg green" onclick="print()"&gt;&lt;i class="fa fa-print" aria-hidden="true" style="padding-right: 5px;"&gt;&lt;/i&gt;Print&lt;/a&gt; 
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to print the table which is in the new window. Can anyone help me to achieve this?? Any help will be appreciated.</p>