网页计数器问题!!!

来源:百度知道 编辑:UC知道 时间:2024/09/21 00:44:14
<%
CountFile=Server.MapPath("count.txt")
'文件cont.txt是用来储存数字的文本文件,初始内容一般是0(别弄虚作假哦)
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
'方法Application.lock禁止别的用户更改计数器的值
counter= counter +1
'计数器的值增加1
Out.WriteLine(counter)
'把新的计数器值写入文件
Application.unlock
'使用方法Application.unlock后,允许别的用户更改计数器的值
Response.Write(counter)
'把计数器的值传送到浏览器,以红(red)色显示给用户
Out.Close
'关闭文件
%>

这是一个网页计数器代码 我如何修改让他能20秒加一次访问量
下面这段也是一个,怎么样去上面结合起来
<%
function counts(counterfile)
dim objfso,objts
application.lock '锁定对象
set objfso=server.cr

存在你自己机器的统计数,20秒更新一次有什么用呢, 你可以直接每次增加100万~

如果你真想20秒更新一次,那么你可以考虑这样做。首先是编写一个counter.asp,内容就是你补充的那一段,然后在别的文件里面20秒调用一次,代码如下:

<iframe name=count_frm style='display:none'></iframe>
<script type=text/javascript>
function up_counter(){
count_frm.location.href='counter.asp';
setTimeout('up_counter();', 20000);//20秒执行一次
}
up_counter();
</script>

ASP 没有定时运行的。。。