有两种方法:1.纯html + javascript-------print.js--------------------------- var hkey_root, hkey_path, hkey_key; hkey_root = "HKEY_CURRENT_USER"; hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; //网页打印时清空页眉页脚 function pagesetup_null() { try { var RegWsh = new ActiveXObject("WScript.Shell") hkey_key = "header" RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "") hkey_key = "footer" RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "") } catch (e) { } } //网页打印的时恢复页眉页脚为默认值 function pagesetup_default() { try { var RegWsh = new ActiveXObject("WScript.Shell") hkey_key = "header" RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "&w&bPage &p of &P") hkey_key = "footer" RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "&u&b&d") } catch (e) { } } function doPrint(printDiv) { try { pagesetup_null(); newwin = window.open("", "newwin", "height=900,width=700,toolbar=no,scrollbars=auto,menubar=no"); newwin.document.body.innerHTML = document.getElementById(printDiv).innerHTML; newwin.window.print(); newwin.window.close(); pagesetup_default(); } catch (e) { } }----------------------------------------------------------------------------------------前面: <script language=javascript src=printer.js></script><div>DIV1 , do not print me</div><div id="myDiv">Line2 , need print</div><div>Line3 , do not print me</div><div> <input type="button" id="bt" onclick="javascript:doPrint('myDiv')" value="Print" />-----------------------------------------------------------------------------------------------------------上面的方法简单好用,只需要把打印的内容放在mydiv里面就行了。但是如果对方访问的时候没有加域,没有权限去修改别人的注册表的话,会出现页眉页脚。2.用水晶报表做 追问 小票高度是随着商品数量改变的,这个高度怎么能让它自动加呢?
用并口打印机,比如POS58或者EPSON等微打,装好驱动,设置成默认打印机 打印页面版面调整好,主要注意超宽的地方,可以用表格限制 调用window.print()打印即可set objfs=CreateObject( "Scripting.FileSystemObject ") '创建FileSystem组件对象的实例 set objprinter=objfs.CreateTextFile ( "LPT1: ",true) '建立与打印机的连接 objprinter.Writeline "万年春贵宾卡结账单 客户联 " '输出打印的内容 objprinter.Writeline "------------------------------- " objprinter.Writeline "日期 "&chr(58)&date()& " 卡号 "&chr(58)&code objprinter.Writeline " " objprinter.Writeline "消费金额 "&chr(58)&formatcurrency(sjmoney) objprinter.Writeline " " objprinter.Writeline "享受 "&codezk& "折优惠 " objprinter.Writeline " " objprinter.Writeline "实收金额 "&chr(58)&formatcurrency(money) objprinter.Writeline " " objprinter.Writeline "------------------------------- " objprinter.Writeline " " objprinter.Writeline "收银员 "&chr(58)&admin& " 顾客签名:_________ " objprinter.Writeline chr(13) objprinter.Writeline chr(13) objprinter.Writeline chr(13) 以前写的,你试一下