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

2019-05-10 19:15发布

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

2条回答
神经病院院长
2楼-- · 2019-05-10 19:48

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.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-05-10 19:53

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.

查看更多
登录 后发表回答