中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > Web开发 > Asp > 综合文章
用asp"PrintthisPage"
作者:佚名 时间:2004-10-08 10:44 出处:互连网 责编:chinaitpower
              摘要:用asp"PrintthisPage"
东子 于 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>
好好享用!
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有