在静态网页中增加访问计数器的方法
上一篇 /
下一篇 2007-08-27 15:22:23
/ 个人分类:ASP
51Testing软件测试网1dcsRS 静态网页一般不能动态的显示当前页面的浏览次数,但是我们可以通过一个单独的asp文件和javascrīpt脚本来实现这一点。51Testing软件测试网5L{-a \%\
51Testing软件测试网#LN'_;}s+o:g1.在静态页面生成的时候要插入这样一段代码:
-N!zI,X(FiK+k8M0<scrīpt src="/hit.asp?url=<%=request.ServerVariables("URL")%><%if request.ServerVariables("QUERY_STRING")<>"" then%><%="?"&request.ServerVariables("QUERY_STRING")%><%end if%>"></scrīpt>51Testing软件测试网&|$l1I*gX9k/^
2.hit.asp文件内容:
%U1r?)r#g#|+x0J;Z;an#DKE0<!--#include file="admin/inc/addconn.asp" -->
J!t_N)}Y T'BK;{0<%51Testing软件测试网+atQ&c3zX/L1[
url=request("url")
J[6lfh{B0 set rs=server.createobject("adodb.recordset")
#D2P-x;Fxst7p0 sql="select * from pagehit where url like '"&url&"'"
1X
L)t3~bi0 rs.open sql,conn,1,3
&h%f(Sa+Q"uV0 if rs.eof then51Testing软件测试网pNS BJ;m@.n
rs.addnew
-C
|?V:v(w*A4u0 rs("url")=url
K3} [mq/o"f+nA0 rs("hit")=151Testing软件测试网+G8?1W:kMr
else51Testing软件测试网J2f5}]1e~:HD9|
rs("hit")=rs("hit")+151Testing软件测试网&?qYxv0f @D A7Z
end if
j&Tc
]*yF1W0 hit=rs("hit")51Testing软件测试网;t)H8h9^%f"K
rs.update51Testing软件测试网`fW*Pk%v q
rs.close51Testing软件测试网D%Fs@*A
set rs=nothing51Testing软件测试网F.Y}
xC)x
conn.close
APbepQUlM(H0 set conn=nothing51Testing软件测试网X}x._%o6` }2Sg#w
%>51Testing软件测试网&j"N#N] Gn6omq#U
document.write(<%=hit%>)
/ce8n F$Y
[k0
相关阅读:
- 分页存储过程 (紫忧, 2007-6-05)
- 分页代码 (紫忧, 2007-6-22)
- 加快网页的打开速度 (紫忧, 2007-6-25)
- 避免asp的SQL的执行效率低 (紫忧, 2007-7-03)
- asp与存储过程 (紫忧, 2007-7-11)
- ASP 编程中20个非常有用的例子 (紫忧, 2007-7-19)
- Vista系统配置IIS7+Asp+Access (云层, 2007-8-15)
- 利用Adodb.Stream制作彩色验证码 (紫忧, 2007-8-15)
- adodb.stream对象的方法/属性 (紫忧, 2007-8-17)
- 过滤网址的非法字符串 (紫忧, 2007-8-21)
收藏
举报
TAG:
ASP