how to remove print header/footer with code

前端 未结 1 1354
栀梦
栀梦 2020-12-21 05:11

I am using the following code to print a page within my application...

\"
  sHtmlBody = sHtmlBody &         


        
相关标签:
1条回答
  • 2020-12-21 05:55

    you can do with the help of CSS , before print set the CSS of the page . for example:

    <style type="text/css">
    @media print{
      body{ background-color:#FFFFFF; background-image:none; color:#000000 }
      #ad{ display:none;}
      #leftbar{ display:none;}
      #contentarea{ width:100%;}
    }
    </style>
    

    This code when added to the page hides the 2 divs with ids "ad" and "leftbar", plus makes additional changes to the rest of the document when it's printed.

    IF you are asking about browser specific settings like print date and time , then i think it is not possible through code. check this out : Remove the default browser header and footer when printing HTML

    0 讨论(0)
提交回复
热议问题