2,在**head中引入**
@media screen{.onlyPrint{display:none}} @media print{.onlyShow{display:none} .onlyPrint{page-break-before:always}}
然后剩下的js操作就可以了;
3,
function printsetup() { // 打印页面设置 factory.printing.PageSetup(); } function doPrint() { if (confirm('确定打印吗?')) { document.all.factory.printing.header = ""; //页眉 document.all.factory.printing.footer = ""; //页脚 //设置边距 document.all.factory.printing.leftMargin = 19.05;//left document.all.factory.printing.topMargin = 19.05;//top document.all.factory.printing.rightMargin = 19.05;//right document.all.factory.printing.bottomMargin = 19.05;//bottom document.all.factory.printing.portrait = false; //横向打印 document.all.factory.printing.Print(false); //只打印当前frame,不管是否隐藏 } } <center class=aaa> <input onclick=javascript:printsetup(); type=button value=打印页面设置 name=button_setup /> <input onclick=javascript:doPrint(); type=button value=打印 name=button_print /> </center>
根据自己实际情况设置初始参数,如需保存更改的打印设置的参数,可以考虑使用JavaScript设置cookie进行操作。
原文地址:http://blog.51cto.com/10556290/2046403