如何只打印页面的一部分? [英] How to print only parts of a page?

查看:179
本文介绍了如何只打印页面的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户打印这个巨型窗体之前隐藏一些div,然后再显示div。因此,我想忽略页面的其余部分,只打印表单本身。

I am trying to hide some divs before the user prints this giant form, then display the divs again afterward. Thus I want to ignore the rest of the page, and only print the form itself.

当用户打开一个单独的页面时,单击打印按钮。唯一的事情是,形式真的很长,这是非常繁琐的。

Sure I could open a separate page when the user clicks the print button. The only thing is that the form is really long and it would be quite tedious to do that.



编辑:我上一个问题没有反映我所寻找的。所以我把它改为现在的。


My previous question did not actually reflect what I was looking for. So I changed it to the current one.

还要感谢所有建议window.onbeforeprint和window.onafterprint。

Also thanks to all that suggested window.onbeforeprint and window.onafterprint. That was relevant to my edited question.

推荐答案

IE支持 onbeforeprint onafterprint ,但你真正想要的是一个打印样式表。

IE supports onbeforeprint and onafterprint, but what you really want is a print stylesheet.

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

另请参阅:此答案

这篇关于如何只打印页面的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆