title: How to remove print header/footer with code
body: <p>I am using the following code to print a page within my application...</p>
  
  <pre><code>&lt;html&gt;&lt;body onload=""window.print();""&gt;"
    sHtmlBody = sHtmlBody &amp; "&lt;body&gt;"
  </code></pre>
  
  <p>The <code>window.print()</code> is working fine.
  I know once the print comes up I can manually go into the settings and remove headers and footer.
  On IE I know that I have to go to print preview and then remove the print headers.</p>
  
  <p>However, is there some line of code which does this automatically so the users of the application don't have to do this?</p>
  
  <p>EDIT:</p>
  
  <pre><code> sHtmlBody = "&lt;style type='text/css'&gt;"
        sHtmlBody = sHtmlBody &amp; " @media print{"
        sHtmlBody = sHtmlBody &amp; " body{ background-color:#FFFFFF; background-image:none; color:#000000 }"
        sHtmlBody = sHtmlBody &amp; " #ad{ display:none;}"
        sHtmlBody = sHtmlBody &amp; " #leftbar{ display:none;}"
        sHtmlBody = sHtmlBody &amp; " #contentarea{ width:100%;}"
        sHtmlBody = sHtmlBody &amp; " }"
        sHtmlBody = sHtmlBody &amp; " &lt;/style&gt;"
        sHtmlBody = sHtmlBody &amp; "&lt;html&gt;&lt;body onload=""window.print();""&gt;"
        sHtmlBody = sHtmlBody &amp; "&lt;body&gt;"
  </code></pre>