New Document dim hkey_root,hkey_path,hkey_key hkey_root="HKEY_CURRENT_USER" hkey_path="\Software\Microsoft\Internet Explorer\PageSetup" '//设置网页打印的页眉页脚为空 function pagesetup_null() on error resume next Set RegWsh = CreateObject("WScript.Shell") hkey_key="\header" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"" hkey_key="\footer" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"" end function '//设置网页打印的页眉页脚为默认值 function pagesetup_default() on error resume next Set RegWsh = CreateObject("WScript.Shell") hkey_key="\header" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P" hkey_key="\footer" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d" end function
4、浮动帧打印 function button1_onclick() { var doc=window.iframe1.document; var r=odoc.body.createTextRange(); var stxt=r.htmlText; alert(stxt) var pwin=window.open("","print"); pwin.document.write(stxt); pwin.print(); }
4、用FileSystem组件实现WEB应用中的本地特定打印 function print_onclick //打印函数 dim label label=document.printinfo.label.value //获得HTML页面的数据 set bjfs=CreateObject("Scripting.FileSystemObject") //创建FileSystem组件对象的实例 set bjprinter=objfs.CreateTextFile ("LPT1:",true) //建立与打印机的连接 objprinter.Writeline("__________________________________") //输出打印的内容 objprinter.Writeline("| |") objprinter.Writeline("| 您打印的数据是:"&label& " |”) objprinter.Writeline("| |") objprinter.Writeline("|_________________________________|") objprinter.close //断开与打印机的连接 set bjprinter=nothing set bjfs=nothing // 关闭FileSystem组件对象 end function
服务器端脚本: <%……… set conn=server.CreateObject ("adodb.connection") conn.Open "DSN=name;UID=XXXX;PWD=XXXX;" set rs=server.CreateObject("adodb.recordset") rs.Open(“select ……”),conn,1,1 ……….%> //与数据库进行交互 HTML页面编码: