计数器源代码
AspScript和AspVBscript其实是同一个东西,asp脚本一般用VBScript编写,也有的用java script编写(功能是一样的),不过用vbs的比较多。 你要加计数器的话,要看你购买的空间支持哪些脚本 一般win2000主机支持ASP(即VBScript),cgi等,linux主机支持php,jsp,cgi。
如果你确定使用支持asp的空间,就要找asp编写的计数器。 站点的访问计数器一般比较简单。 下面是一个简单的基于文本的图形计数器,统计次数放在一个文本文件count.txt里 这个计数器包括如下文件: counter.asp ---执行计数功能 count.txt---存放数字 c0.gif,c1.gif.....c9.gif ---0-9的图形,你要是想换成漂亮的计数器,只要替换这些图形就可以
下面是计数器counter.asp的源代码(需要你的空间支持FSO功能) <html> <head> <title>counter</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body bgcolor="#000000" text="#000000"> <% dim visitors,fs whichfile=server.mappath("count.txt") Set fs = CreateObject("Scripting.FileSystemObject") Set thisfile = fs.OpenTextFile(whichfile)
visitors=thisfile.readline thisfile.close
countlen=len(visitors) countsize=7 if countlen<countsize and i<countlen then for j=1 to (countsize-countlen) res0402ponse.write "<img src=""c0.gif""></img>" next for i=1 to countlen res0402ponse.write "<img src=""c" & mid(visitors,i,1) & ".gif""></img>" next end if
visitors=visitors+1 Set out=fs.CreateTextFile(whichfile) out.WriteLine(visitors) out.close
set fs=nothing %> </body> </html>
你可以把上面这些文件都放到一个count目录里面,便于管理 显示的时候在网页需要显示计数器的位置插入如下源代码 <iframe bgcolor="#000000" src="count/counter.asp" width="63" height="15" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>
一个简单的计数器就可以使用了。
希望对大家有点用...
|