2、分页打印 <HTML> <HEAD> <STYLE> P {page-break-after: always} </STYLE> </HEAD> <BODY> <%while not rs.eof%> <P><%=rs(0)%></P> <%rs.movenext%> <%wend%> </BODY> </HTML>
3、ASP页面打印时如何去掉页面底部的路径和顶端的页码编号 (1)ie的文件-〉页面设置-〉讲里面的页眉和页脚里面的东西都去掉,打印就不出来了。 (2)<HTML> <HEAD> <TITLE>NewDocument</TITLE> <META.NAME="Generator"CONTENT="EditPlus"> <META.NAME="Author"CONTENT="YC"> <script.language="VBScript"> 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 </script> </HEAD>
</p> </BODY> </HTML> 4、浮动帧打印 <SCRIPT.LANGUAGE=javascript> 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(); } </SCRIPT> 4、用FileSystem组件实现WEB应用中的本地特定打印 <script.Language=VBScript> 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("| 您打印的数据是:"&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页面编码: