用asp "Print this Page" - 中国WEB开发者网络 (http://www.webasp.net) -- 技术教程 (http://www.webasp.net/article/) --- 用asp "Print this Page" (http://www.webasp.net/article/1/531.htm) |
| -- 作者:未知 -- 发布日期: 2003-04-15 |
| 东子 于 00-9-3 上午 01:41:46 发表在:ASP地带
用此引用该程序 <A HREF="/ASPScripts/PrintPage.asp?REF=URL_of_Web_Page"> 打印 </A> PrintPage.asp 原程序 <%@ Language=VBScript %> <% Option Explicit %> <HTML> <HEAD> <TITLE> 4GuysFromRolla.com Article </TITLE> </HEAD> <BODY> <CENTER> <TABLE WIDTH=90% BORDER=2 CELLSPACING=1 BGCOLOR=WHITE> <TR><TD ALIGN=CENTER> <FONT SIZE=3><I> This article was brought to you by 4GuysFromRolla.com! When you think ASP, think 4GuysFromRolla.com!<BR> http://www.4GuysFromRolla.com </FONT></I> </TD></TR> </TABLE> </CENTER> <P> <% Const ForReading = 1 Dim strReferrer, objFSO, objOpenFile, strLine strReferrer = Request.QueryString("REF") If Len(strReferrer) < 1 then strReferrer = Request.ServerVariables("HTTP_REFERER") If Len(strReferrer) < 1 then Response.Write "Egad! An Error occurred! We could not" & _ " determine what page you wanted to view the source for..." Response.End Else 'With the HTTP_REFERER, the entire URL is passed along... we 'need to hack out the http://www.4guysfromrolla.com part strReferrer = Right(strReferrer,len(strReferrer)-7) strReferrer = Right(strReferrer,len(strReferrer) - _ instr(1,strReferrer,"/")+1) End If End If 'Make sure the user isn't trying to view ASP source If InStr(1,UCase(strReferrer),"/WEBTECH/") = 0 OR _ InStr(1,strReferrer,"..") <> 0 then 'Shame on you, trying to view a page you're not suppose to... Response.Write "Only pages in the /webtech/" & _ " directory may be viewed in printer-friendly format..." Response.End End If Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objOpenFile = objFSO.OpenTextFile(Server.MapPath(strReferrer), _ ForReading) 'There is a line in each article, ' <% strPageTitle = "Article Name to display in TITLE Tag" %> 'There's no need to spit this out... Do Until objOpenFile.AtEndOfStream strLine = objOpenFile.ReadLine If InStr(1, strLine, "<% strPageTitle = ") = 0 then Response.Write strLine & vbCrLf End If Loop objOpenFile.Close Set objOpenFile = Nothing Set objFSO = Nothing %> <P><HR><P><CENTER><FONT SIZE=2><I> This article was brought to you by 4GuysFromRolla.com! When you think ASP, think 4GuysFromRolla.com!<BR> http://www.4GuysFromRolla.com</FONT></I></CENTER><P> </BODY> </HTML> 好好享用! |
| webasp.net |