How can I print a certain block/part of a web page?

試著忘記壹切 提交于 2019-12-07 13:32:22

问题


How can I print a certain block/part of a web page? Print option to look like Print Screen functionality.


回答1:


Use css, with the media = print option.

Like:

<link rel="stylesheet" type="text/css" href="print.css" media="print" />

The blocks you don't want printed can set display:none.




回答2:


See http://www.quackit.com/javascript/javascript_print.cfm

You can use javascript's window.print() to print the page. To restrict the printed content to a specific part of the page, you can create a print stylesheet (see http://www.alistapart.com/articles/goingtoprint/) that hides all but the desired content.



来源:https://stackoverflow.com/questions/2227496/how-can-i-print-a-certain-block-part-of-a-web-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!