ScriptX.cab与Smsx.cab打印代码

<!--前提为必须设置了打印机,即为有默认的打印机,否则此页的弹出窗口不会显示-->


<!--media=print 这个属性可以在打印时有效,设置打印时,打印按钮不显示的样式-->
<style media=print>
.Noprint{display:none;}
.PageNext{page-break-after: always;}
</style>
<!--添加打印组件,注意设置codebase路径-->
<object id="factory"   style="display:none"   viewastext   
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"   
codebase="ScriptX.cab#Version=6,2,433,14">
</object>

<!--calss="noprint"设置打印时不显示打印按钮-->
<td class="noprint" align="right"><img src="" align="right" style="cursor:hand"onClick="set_print()"></td>


<!--此方法为载入页面时,即弹出页面设置窗口-->
<!--以下为常用打印设置-->
<script defer="defer">
function window.onload() {
//advanced   features   这里就是你打印设置的地方
//factory.printing.SetMarginMeasure(2)   //   measure   margins   in   inches   
//factory.printing.SetPageRange(false,   1,   3)   //   need   pages   from   1   to   3   
factory.printing.printer   =   "HP   DeskJet   870C"   
//factory.printing.copies   =   2   
//factory.printing.collate   =   true   
factory.printing.paperSize   =   "B%"   
actory.printing.paperSource   =   "Manual   feed"   
//basic features   
factory.printing.header   =   "居左显示&b居中显示&b居右显示页码,第&p页/共&P页"   
factory.printing.footer   =   "(自定义页脚)"   
factory.printing.portrait   =   false   
factory.printing.leftMargin   = 11   
factory.printing.topMargin   =   1.5   
factory.printing.rightMargin   =   0.75   
factory.printing.bottomMargin   =   1.5
factory.printing.PageSetup() ; //打印设置
factory.printing.Preview() ;        //打印预览
}
</script>



smsx.cab打印页代码(没有弹出页面设置窗口)

<object id="factory" viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="<%=path%>/erpxtbg/tjfx/smsx.cab#Version=6,3,434,26"></object>
<style>
@media print {
.noprint {display:none}
}
.STYLE2 {
font-size: 18px;
font-weight: bold;
}
</style>
<td class="noprint" align="right"><img src="" align="right" style="cursor:hand"onClick="set_print()"></td>

<script language="javascript">
function set_print()
{
factory.printing.header = "";
factory.printing.footer = "";
factory.printing.portrait = 1; //1为纵向打,0为横向打
factory.printing.leftMargin = 13;   //左边距
factory.printing.topMargin = 20;    //右边距
factory.printing.Print(false);
}
</script>

你可能感兴趣的:(HP)