I am using the script below:
我使用下面的脚本:
<script>
function printpage()
{
window.print()
}
</script
To call it after with this:
用这个来调用它:
<input type="button" value="Print this page" onclick="printpage()" />
But I don't know how to insert in the script this:
但是我不知道如何在脚本中插入这个:
$('input' )
.hide();
Meaning that all the input from the print area is hidden.
这意味着隐藏了打印区域的所有输入。
Any ideas?
有任何想法吗?
2 个解决方案
#1
12
You can solve this using CSS by specifying the media type as print
:
您可以通过将媒体类型指定为print来使用CSS解决此问题:
<style type="text/css" media="print">
/*<![CDATA[*/
input{
display:none;
}
/*]]>*/
</style>
#2
3
Use @Media CSS rule:
使用@Media CSS规则:
@media print {
input {visibility:hidden;}
}
or
要么
@media print {
input {display:none;}
}
The choice between these options depends on your page flow: display:none removes the input completely, while visibility:hidden simply hides it, but it still occupies its place.
这些选项之间的选择取决于您的页面流:display:none完全删除输入,而visibility:hidden只是隐藏它,但它仍然占据它的位置。
You don't need to hide it in JavaScript.
您不需要在JavaScript中隐藏它。
#1
12
You can solve this using CSS by specifying the media type as print
:
您可以通过将媒体类型指定为print来使用CSS解决此问题:
<style type="text/css" media="print">
/*<![CDATA[*/
input{
display:none;
}
/*]]>*/
</style>
#2
3
Use @Media CSS rule:
使用@Media CSS规则:
@media print {
input {visibility:hidden;}
}
or
要么
@media print {
input {display:none;}
}
The choice between these options depends on your page flow: display:none removes the input completely, while visibility:hidden simply hides it, but it still occupies its place.
这些选项之间的选择取决于您的页面流:display:none完全删除输入,而visibility:hidden只是隐藏它,但它仍然占据它的位置。
You don't need to hide it in JavaScript.
您不需要在JavaScript中隐藏它。