第一种方法:
<%application.lock
application("user_number")=application("user_number")+1
application.UnLock
response.write "您是第" & application("user_number")&"位访客"
%>
======================================
第二种方法:
1.一个asp文件,一个计数的count.txt文件
asp文件
==========
<%
CountFile=Server.MapPath("count.txt")
Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
Set Out=FileObject.OpenTextFile(CountFile,1,FALSE,FALSE)
counter=Out.ReadLine
Out.Close
SET FileObject=Server.CreateObject("Scripting.FileSystemObject")
Set Out=FileObject.CreateTextFile(CountFile,TRUE,FALSE)
Application.lock
counter= counter + 1
Out.WriteLine(counter)
Application.unlock
Response.Write"您是第"&counter&"位访客"
Out.Close
%>
==========
保存为count.asp,同目录下放一文本文件count.txt,初始数值为任意数字
2.在需要计数的网页加入:
<script language="JavaS
可以加在网页的任何你想要出现的地方
第三种方法:
下面是计数器源代码,你只需要在要统计的页面的同级目录里建一个"count.txt",在里面写上0,再把这段代码放到你要统计的页面里就可以了:
<%
'一个简单的计数器程序
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)
%>
评论