繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> 打印相关 >> 用asp "Print this Page"

用asp "Print this Page"

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:42  文字大小:【】【】【
简介:东子 于 00-9-3 上午 01:41:46 发表在:ASP地带 用此引用该程序 <A HREF="/ASPScripts/PrintPage.asp?REF=URL_of_Web_Page"> 打印 </A> PrintPage.asp 原程序 <%@ Language=VBScr...
关键字:Print Page this asp

东子 于 00-9-3 上午 01:41:46 发表在:ASP地带

用此引用该程序

打印

PrintPage.asp 原程序

<%@ Language=VBScript %>

<% Option Explicit %>

</p> <p>4GuysFromRolla.com Article</p> <p>

This article was brought to you by 4GuysFromRolla.com!

When you think ASP, think 4GuysFromRolla.com!

http://www.4GuysFromRolla.com

<%

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

%>


This article was brought to you by 4GuysFromRolla.com! When you think ASP,

think 4GuysFromRolla.com!

http://www.4GuysFromRolla.com

好好享用!

责任编辑:admin
http://www.3pcode.com/asp/2004/10/3054.htm" />
发表评论 加入收藏 告诉好友 打印本页 关闭窗口 返回顶部
相关文章