文本计数器
1、在网站目录下新建一个文本:txtcounter.txt在文本填写1或其他数字。
2、新建一asp文件:count.asp,加入以下代码:
<%
CountFile=Server.MapPath("txtcounter.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"document.write("&counter&")"
'为了在页面正确显示计数器的值,调用VBScript函数Document.write
Out.Close
%>
3、在需要计数的网页加入:总访问<script language="JavaScript" src="count.asp"></script>次
图形计数器
1、在网站目录下新建一个文本:imgcounter.txt在文本填写1或其他数字。
2、新建一asp文件:imgcounter.asp,加入以下代码:
<%
dim images(20)
'定义一数组,用来存放显示每一位数字图象的语句
CountFile=Server.MapPath("imgcounter.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
countlen=len(counter)
'得到计数器值的位数
for i=1 to countlen
images(i)="<img src="&"img"&"/" & mid(counter,i,1) & ".gif></img>"
'由循环语句得到各个位上数值对应图象的显示代码(html),并把它存在数组中
'具体使用时请注意图象的实际服务器及目录路径
response.write"document.write('"&images(i)&"');"
'调用函数Document.write输出显示数字图象的html代码
next
Out.Close
%>
3、在需要计数的网页加入:总访问<script language="JavaScript" src="imgcounter.asp"></script>次
相关链接:文本计数器和图形计数器
用户登陆
日志分类
精华日志
最新日志
最新评论
站点统计
站点日历
日志搜索
文本计数器和图形计数器 [ 日期:2008-09-02 ] [ 来自: