title: Javascript print is displaying hidden elements
body: <p>I am trying to built a billing system using php and javascript. For that I need to print some content in a new tab. I am using the following code for this purpose. Where the variable <em>divElements</em> contains the inner html of my table that needs to be print.</p>
  
  <pre><code>var print_body =
                    '&lt;!DOCTYPE html&gt;&lt;head&gt;&lt;meta charset="utf-8"&gt;&lt;title&gt;&lt;/title&gt;&lt;link rel="stylesheet" href="style.css" type="text/css"&gt;&lt;/link&gt;&lt;/head&gt;&lt;body style="background:none"&gt;&lt;table class="dop" id="table" border="1" style="border-collapse:collapse;border-style:solid"&gt;'+
                    divElements +'&lt;/table&gt;&lt;/body&gt;';
                  //Print  Page
                    newWin= window.open("");
                    newWin.document.write(print_body);
                    newWin.print();
  </code></pre>
  
  <p>using the class <em>dop</em> I am trying to hide the unwanted elements. In the print preview the the design displaying correctly but when taking printout, the hidden elements are printing in the paper.
  I think the problem is print function is running before the style loads.
  Please help me to solve the issue.</p>
  
  <p>thanku</p>