<!--控制不想打印的内容-->
<style media=print>
.Noprint{display:none;}
</style>
<!--结束 -->
<!--打印js -->
<script defer>
function SetPrintSettings() {
// -- advanced features
factory.printing.SetMarginMeasure(2) // measure margins in inches
factory.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 = "A4"
factory.printing.paperSource = "Manual feed"
// -- basic features
factory.printing.header = "This is MeadCo"
factory.printing.footer = "Advanced Printing by ScriptX"
factory.printing.portrait = false
factory.printing.leftMargin = 1.0
factory.printing.topMargin = 1.0
factory.printing.rightMargin = 1.0
factory.printing.bottomMargin = 1.0
}
</script>
<script language="javascript">
function printsetup(){
// 打印页面设置
document.getElementById('wb').execwb(8,1);
}
function printpreview(){
// 打印页面预览
document.getElementById('wb').execwb(7,1);
}
function printit()
{
//if (confirm('确定打印吗?')) {
document.getElementById('wb').execwb(6,6)
//}
}
</script>
<!-- 打印JS结束 -->
<table width="100%">
<tr>
<td align="center">
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"
height=0 id=wb name=wb width=0></OBJECT>
<input type=button name=button_setup id=wb value="打印页面设置"
οnclick="javascript:printsetup();" class="Noprint">
<input type=button name=button_show id=wb value="打印预览"
οnclick="javascript:printpreview();" class="Noprint">
<input type=button name=button_print id=wb value="打 印"
οnclick="javascript:printit()" class="Noprint">
<input type=button name=button_fh id=wb value="关闭"
οnclick="javascript:window.close();" class="Noprint">
</td>
</tr>
</table>
以上不能解决浏览器对插件的限制可以参考以下
<script language=javascript>
function doprint() {
var bdhtml=window.document.body.innerHTML;
var sprnstr="<!--startprint-->";
var eprnstr="<!--endprint-->";
var prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
window.document.body.innerHTML=bdhtml;
}
</script>
<!--startprint-->
这里面是需要打印的内容
<!--endprint-->
<input type=button name=btnPrint value="打印" onClick="doprint()" style="cursor:hand;padding-top:3;">