JavaScript打印预览 [英] JavaScript print preview

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

问题描述

如何查看从网站产生的月结单的列印预览。如果我使用脚本打印

 < a href =javascript:window.print()& / a>在打印打印此页中打印

如何隐藏?

解决方案

解决您问题的以下部分:


$ b $



如何隐藏?


创建一个新的样式表(在本例中,我命名为print.css),并将其包含在HTML中,如下所示: p>

 < link rel =stylesheethref =print.csstype =text / cssmedia =print > 

请注意 media =print $ c>元素,以便我们可以在CSS中引用它:

 < a href =javascript:window.print class =noPrint>打印此页< / a> 

,包括以下规则:

  .noPrint {
display:none;
}



现在打印此页链接不应出现在打印版您的信息页。



Steve


How can I see print preview of my invoice generated from website. If I print with the script

<a href="javascript:window.print()">print this page</a>

in the print "print this page" also printed. How can I hide it?

解决方案

Addressing the following part of your question:

in the print "print this page also printed .

How can I hide it?

Create a new stylesheet (in this example, I've named it "print.css") and include it in your HTML as follows:

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

Note the media="print"—this means the stylesheet will only be used when printing the page.

Next assign a class to your <a> element so that we can reference it in CSS:

<a href="javascript:window.print()" class="noPrint">Print this Page</a>

Finally, in your CSS file, include the following rule:

.noPrint {
    display: none;
}

Now the "Print this Page" link shouldn't appear in the printed version of your page.

Steve

这篇关于JavaScript打印预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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