请教怎么将这两个代码合起来做一个防刷新的图片计数器啊?
代码一:
<% @language= "VBScript "%>
<%
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= "& "http://www.qdsenda.com/counter/ "& "/ " & mid(counter,i,1) & ".gif> </img> "
'由循环语句得到各个位上数值对应图象的显示代码(html),并把它存在数组中
'具体使用时请注意图象的实际服务器及目录路径
response.write "document.write( ' "&images(i)& " '); "
'调用函数Document.write输出显示数字图象的html代码
next
Out.Close
%>
代码二:
<%
function counts(counterfile)
dim objfso,objts
application.lock '锁定对象
set objfso=server.createobject( "scripting.filesystemobject ")
set objts=objfso.opentextfile(server.mappath(counterfile),1,true)
if not objts.atendofstream then '检查是否到达文件结尾
counts=clng(objts.readline)
end if
counts=counts+1
objts.close
set objts=objfso.opentextfile(server.mappath(counterfile),2,true)
objts.writeline(counts)
objts.close
application.unlock '解除锁定
end function
if session( "counter ")=empty then
session( "counter ")=counts( "counter.txt ")
end if
%>
<HTML>
<body>
您是第 <%=session( "counter ")%> 位访客
</body>
</HTML>
这样一个完美的计数器就做成了。
代码一是一个图片计数器的代码,但是没有防刷新功能;代码二是具有防刷新功能的文本计数器。
请问怎么将二者合一制作一个防止刷新的计数器啊,谢谢
------解决方案-------------------- <%
function counts(counterfile)
dim images
'定义一数组,用来存放显示每一位数字图象的语句
CountFile=Server.MapPath(counterfile)
Set FileObject=Server.CreateObject( "Scripting.FileSystemObject ")
application.lock
Set Out=FileObject.OpenTextFile(CountFile,1,FALSE,FALSE)
if not Out.atendofstream then
counter=clng(Out.ReadLine)
end if
Out.Close
counter=counter+1
SET FileObject=Server.CreateObject( "Scripting.FileSystemObject ")
Set Out=FileObject.CreateTextFile(CountFile,TRUE,FALSE)
Out.WriteLine(counter)
Out.Close
Application.unlock
countlen=len(counter)
'得到计数器值的位数
for i=1 to countlen
images= " <img src= "& "http://www.qdsenda.com/counter/ "& "/ " & mid(counter,i,1) & ".gif> </img> "
'由循环语句得到各个位上数值对应图象的显示代码(html),并把它存在数组中
'具体使用时请注意图象的实际服务器及目录路径
respons