简体   繁体   English

删除html中的页眉和页脚以打印页面

[英]Remove header and footer in html to print page

Is there any way to remove header and footer of a html page, so that if user print it, there is no header and footer. 有没有办法删除html页面的页眉和页脚,以便如果用户打印它,没有页眉和页脚。

User can choose to remove it using print setup, but i wondering is there any css or javascript to remove it programatically? 用户可以选择使用打印设置删除它,但我想知道是否有任何CSS或JavaScript以编程方式删除它?

thank you for any response. 谢谢你的回复。

I do some googling and everybody said: "Can't remove them!" 我做了一些谷歌搜索,每个人都说:“不能删除它们!” except using ActiveX and 3rd party plugins. 除了使用ActiveX和第三方插件。

I wonder why some reporting controls (Telerik Reporting, DevX,...) can hide Header & Footer without using ActiveX or plugins! 我想知道为什么一些报告控件(Telerik Reporting,DevX,...)可以隐藏页眉和页脚而不使用ActiveX或插件! Are they print the page in another ways? 他们是以其他方式打印页面吗? What way? 有什么办法?

You seem to be referring to the header and footer lines that the browser is adding and not contents of the printed page. 您似乎指的是浏览器添加的页眉和页脚行,而不是打印页面的内容。 In that case the answer is: No, you can only change it in the settings. 在这种情况下,答案是:不,您只能在设置中更改它。

You can do like: 你可以这样做:

   @media print
   {
      .noprint { display: none; }
   }

Now you can apply the noprint class to element you want to hide in printing. 现在,您可以将noprint类应用于要在打印中隐藏的元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM