function pritinf() {
var nw = window.open('', '', 'width=800,height=600');
nw.document.open("text/html", "GB2312");
nw.document.write('<link rel="stylesheet" type="text/css" href="css/css2.css" />');
nw.document.write('<body>');
nw.document.write("<object classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2' id='wb'height='0' width='0'></object>");
nw.document.write(document.getElementById("div1").outerHTML);//这里document.getElementById("div1").outerHTML改成你的tableID
nw.document.write("<scrip" + "t>document.all.wb.ExecWB(6,1)</sc" + "ript>");
nw.document.write('</body>');
} 转载于:https://www.cnblogs.com/zhwl/archive/2011/04/09/2010169.html
本文介绍了一种使用JavaScript实现的窗口打印功能,该方法通过创建一个新的浏览器窗口并写入指定表格的HTML内容来实现。此外,还利用了ActiveX控件来触发浏览器的打印对话框。
140

被折叠的 条评论
为什么被折叠?



