直接调用打印:
<a href="javascript:window.print();">打印</a>
提供打印,预览,设置等按钮:
<html>
<style media="print">
.noprint { display: none }
</style>
</head>
<body>
<script language="JavaScript">
function doPrintSetup(){
//打印设置
WB.ExecWB(8,1)
}
function doPrintPreview(){
//打印预览
WB.ExecWB(7,1)
}
function doprint(){
//直接打印
WB.ExecWB(6,6)
}
</script>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=10 id=WB width=10></OBJECT>
<script >
function window.onload() {
//factory.printing.paperSize = "A3"
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.portrait = false
idPrint1.disabled = false; // enable UI button
idPrint2.disabled = false;
idPrint3.disabled = false;
idPrint4.disabled = false;
factory.printing.leftMargin = 0.75
factory.printing.topMargin = 1.5
factory.printing.rightMargin = 0.75
factory.printing.bottomMargin = 1.5
}
</script>
<div class=noprint>
<input id="idPrint1" type="button" value="打印本页"
οnclick="doprint();">
<input id="idPrint2" type="button" value="页面设置"
οnclick="doPrintSetup();">
<input id="idPrint3" type="button" value="打印预览"
οnclick="doPrintPreview();">
<input id="idPrint4" type="button"
οnclick="window.close()" value="关闭窗口">
</div>
<br/>
<table width="720" border="0" cellspacing="0" cellpadding="0" align="center" >
<tr>
<td bgcolor="#0099ff">
放入要打印的内容
</td>
</tr></table></body> </html>
提供打印,预览,设置等按钮:
<html>
<style media="print">
.noprint { display: none }
</style>
</head>
<body>
<script language="JavaScript">
function doPrintSetup(){
//打印设置
WB.ExecWB(8,1)
}
function doPrintPreview(){
//打印预览
WB.ExecWB(7,1)
}
function doprint(){
//直接打印
WB.ExecWB(6,6)
}
</script>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=10 id=WB width=10></OBJECT>
<script >
function window.onload() {
//factory.printing.paperSize = "A3"
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.portrait = false
idPrint1.disabled = false; // enable UI button
idPrint2.disabled = false;
idPrint3.disabled = false;
idPrint4.disabled = false;
factory.printing.leftMargin = 0.75
factory.printing.topMargin = 1.5
factory.printing.rightMargin = 0.75
factory.printing.bottomMargin = 1.5
}
</script>
<div class=noprint>
<input id="idPrint1" type="button" value="打印本页"
οnclick="doprint();">
<input id="idPrint2" type="button" value="页面设置"
οnclick="doPrintSetup();">
<input id="idPrint3" type="button" value="打印预览"
οnclick="doPrintPreview();">
<input id="idPrint4" type="button"
οnclick="window.close()" value="关闭窗口">
</div>
<br/>
<table width="720" border="0" cellspacing="0" cellpadding="0" align="center" >
<tr>
<td bgcolor="#0099ff">
放入要打印的内容
</td>
</tr></table></body> </html>