62,046
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>打印</title>
</head>
<body>
<object id="factory" viewastext style="display:none"
codeBase="scriptx/ScriptX.cab#Version=6,1,429,14"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814">
</object>
<form id="form1" runat="server">
<input type="button" id="cmdPRINT" onclick="printReport()" value="打印" />
<input type="button" id="butColes" onclick="window.close();" value="关闭" />
<table border="0" cellspacing="0" cellpadding="2" align="center" id="TableDayin">
<tr>
<td align="center" style="height:100px"><font size="2" face="宋体">
打印的内容</font></td>
</tr>
</table>
</form>
</body>
<script type="text/javascript" language="javascript">
//用于设置打印参数
function printBase() {
factory.printing.portrait = true; //true为纵向打印,flase为横向打印
factory.printing.leftMargin = 1.5; //左页边距
factory.printing.topMargin = 0; //上页边距
factory.printing.rightMargin = 1.5; //右页边距
factory.printing.bottomMargin = 0; //下页边距
}
//用于调用设置打印参数的方法和显示预览界面
function printReport() {
//打印时隐藏"打印"按钮和"关闭"按钮
var cmdPRINT = document.getElementById("cmdPRINT");
cmdPRINT.style.visibility = "hidden";
var butColes = document.getElementById("butColes");
butColes.style.visibility = "hidden";
printBase();
factory.printing.Print(false); //false为默认打印机,true为选择打印机
//打印完成后显示"打印"按钮和"关闭"按钮
cmdPRINT.style.visibility = "visible";
butColes.style.visibility = "visible";
}
</script>
</html>