1:用记事本建立counter.cnt 文件,内容为1,或你想起始的数字 2:建立counter.asp 内容如下: <% dim path,myFile,read,write,cntNum path=server.mappath("counter.cnt") read=1 write=2 Set myFso = Server.CreateObject("Scripting.FileSystemObject") set myFile = myFso.opentextfile(path,read) cntNum=myFile.ReadLine myFile.close cntNum=cntNum+1 set myFile = myFso.opentextfile(path,write,TRUE) myFile.write(cntNum) myFile.close set myFile=nothing set myFso=nothing %> document.write('访问次数 <%=cntNum%> 次'); 3:在你想要统计的页面放入代码: 此处注意代码所在的文件夹目录,若要统计的页面在根目录下,而counter.asp 在aspcount目录下 则代码为: <script language="javascript" src="aspcount/counter.asp"></script>
|