2005/03/07 | 网站访问量统计(文字&图片)
类别(ASP) | 评论(0) | 阅读(303) | 发表于 10:14
1.先准备0-9图片各一张
2.将下面代码插入需要显示访问量的页面中
<%
Set Fs=Server.CreateObject("Scripting.FileSystemObject") '创建文件操作对象
file_path=Server.MapPath("./counter.txt") '获得文件路径
Set CounterFile=Fs.OpenTextFile(file_path) '选择记录浏览记录的文档
OldCountervalue=CounterFile.ReadLine '读取原有记录资料
NewCountervalue=OldCountervalue+1 '原有记录资料增加1
CounterFile.Close '关闭文件
Set CounterFile=Fs.OpenTextFile(file_path,2) '打开记录浏览记录的文档--counter.txt?可以写入模式
CounterFile.WriteLine(NewCountervalue) '将新的浏览记录写入文档
CounterFile.Close '关闭文档

Function G_Split(Countervalue,Counter_bits)
For i=1 To Counter_bits
G=Mid(Countervalue,i,1)
If G="" Then
G=0
ImgTag="<img src='./"&G&".gif' width='15' height='15'>"&ImgTag
Else
ImgTag=ImgTag&"<img src='./"&G&".gif' width='15' height='15'>"
End If
Next
G_Split=ImgTag
End Function

%>
<html>
<head>
<title>网上书店</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>您是第&nbsp;<b><%=NewCountervalue%></b>&nbsp;访问者</td>
<td>您是第&nbsp;<%=G_Split(NewCountervalue,6)%>&nbsp;访问者</td>
</tr>
</table>
</body>
</html>
0

评论Comments

日志分类
首页[142]
Diary[42]
Flash[8]
JS/CSS/XHTML[34]
ASP[29]
ASP.NET[2]
Database[6]
Extension[1]
Other[17]
Production[3]