东子 于 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 isnt 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 youre 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" %>
theres 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>
好好享用!
