jQuery 如何在浏览器中禁用某些页面的打印选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3359963/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable printing options in the browser for certain pages
提问by user339108
Env: jQuery,richfaces,all major browsers
环境:jQuery、richfaces、所有主流浏览器
How to disable printing options in the browser for certain pages (e.g. File-->Print Preview, Print)
如何在浏览器中禁用某些页面的打印选项(例如文件--> 打印预览、打印)
回答by Abhijeet Pathak
You cannot disable the actual buttions/menu items but you can use following in required pages to prevent printing:
您不能禁用实际按钮/菜单项,但您可以在所需页面中使用以下内容来防止打印:
<style type="text/css" media="print">
BODY {display:none;visibility:hidden;}
</style>
回答by Sarfraz
You can not disable the browser print buttons, however you can use print @media CSS to hide certain parts or whole page completely from printing. For example, you can use CSS such as this:
您不能禁用浏览器打印按钮,但是您可以使用 print @media CSS 来完全隐藏某些部分或整个页面以防止打印。例如,您可以使用这样的 CSS:
@media print {
html, body {
display: none; /* hide whole page */
}
}