
在一个ASP文件中的适当位置,加入下列代码:
<%
'一个简单的网页计数器
Set fs=CreateObject("Scripting.FileSystemObject")
Set a=fs.openTextFile(server.mappath("count.txt"))
count=a.readline
response.write " " & count
count=count+1
Set fs=CreateObject("Scripting.FileSystemObject")
Set a=fs.createTextfile(server.mappath("count.txt"))
a.writeline(count)
%>
保存ASP文件(比如:index.asp),发送到web服务器你的网站目录。
然后在该ASP文件所在的目录创建一个名叫count.txt的文件 (可以通过xp自带的记事本创建),在该count.txt文件中写上1,这样当网民浏览该ASP网页时,就能在适当位置看到1,并且每浏览一次该网页就增加一个数。
< %
If Application("NumVisits")< 999 then
Application("NumVisits")=999
End If
Application.Lock
Application("NumVisits")=Application("NumVisits")+1
Application.Unlock
%>
欢迎光临本网页,你是本页的第 < %= Application("NumVisits") %> 位访客 !
999为初始值