ScriptX.cab打印代码(有弹出页面设置窗口)
1<!--前提为必须设置了打印机,即为有默认的打印机,否则此页的弹出窗口不会显示-->
2
3<!--media=print 这个属性可以在打印时有效,设置打印时,打印按钮不显示的样式-->
4<style media=print>
5.Noprint{display:none;}
6.PageNext{page-break-after: always;}
7</style>
8<!--添加打印组件,注意设置codebase路径-->
9<object id="factory" style="display:none" viewastext
10classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
11codebase="ScriptX.cab#Version=6,2,433,14">
12</object>
13
14<!--calss="noprint"设置打印时不显示打印按钮-->
15<td class="noprint" align="right"><img src="" align="right" style="cursor:hand"onClick="set_print()"></td>
16
17
18<!--此方法为载入页面时,即弹出页面设置窗口-->
19<!--以下为常用打印设置-->
20<script defer="defer">
21function window.onload() {
22factory.printing.printer = "HP DeskJet 870C"
23factory.printing.paperSize = "B%"
24actory.printing.paperSource = "Manual feed"
25factory.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页"
26factory.printing.footer = "(自定义页脚)"
27factory.printing.portrait = false
28factory.printing.leftMargin = 11
29factory.printing.topMargin = 1.5
30factory.printing.rightMargin = 0.75
31factory.printing.bottomMargin = 1.5
32factory.printing.PageSetup() ; //打印设置
33factory.printing.Preview() ; //打印预览
34}
35</script>
smsx.cab打印页代码(没有弹出页面设置窗口)
1<object id="factory" viewastext style="display:none"
2classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
3codebase="<%=path%>/erpxtbg/tjfx/smsx.cab#Version=6,3,434,26"></object>
4<style>
5@media print {
6.noprint {display:none}
7}
8.STYLE2 {
9font-size: 18px;
10font-weight: bold;
11}
12</style>
13<td class="noprint" align="right"><img src="" align="right" style="cursor:hand"onClick="set_print()"></td>
14
15<script language="javascript">
16function set_print()
17{
18factory.printing.header = "";
19factory.printing.footer = "";
20factory.printing.portrait = 1; //1为纵向打,0为横向打
21factory.printing.leftMargin = 13; //左边距
22factory.printing.topMargin = 20; //右边距
23factory.printing.Print(false);
24
25}
26</script>