用asp Print this Page

來源:互聯網
上載者:User
東子 於 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>
好好享用!



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.