ASP计数器防止页面刷新 10
<%functiondigital(counter)dimi,mystr,scounterscounter=cstr(counter)fori=1to5-len(scou...
<%
function digital(counter)
dim i,mystr,scounter
scounter=cstr(counter)
for i=1 to 5-len(scounter)
mystr=mystr&"<img src=e:\系统\img\0.gif>"
next
for i=1 to len(scounter)
mystr=mystr&"<img src=e:\系统\img\"& mid(scounter,i,1) &".gif>"
next
digital=mystr
end function
application.lock
application("counter")=application("counter")+1
application.unlock
%> 展开
function digital(counter)
dim i,mystr,scounter
scounter=cstr(counter)
for i=1 to 5-len(scounter)
mystr=mystr&"<img src=e:\系统\img\0.gif>"
next
for i=1 to len(scounter)
mystr=mystr&"<img src=e:\系统\img\"& mid(scounter,i,1) &".gif>"
next
digital=mystr
end function
application.lock
application("counter")=application("counter")+1
application.unlock
%> 展开
展开全部
新建一个空的文本文件count.txt用来储存计数器值,然后打开count.txt输入默认值0,再把下面代码保存为count.asp,与count.txt放在同一目录下。
<%
function digital(counter)
dim i,mystr,scounter
scounter=cstr(counter)
for i=1 to 5-len(scounter)
mystr=mystr&"<img src=e:\系统\img\0.gif>"
next
for i=1 to len(scounter)
mystr=mystr&"<img src=e:\系统\img\"& mid(scounter,i,1) &".gif>"
next
digital=mystr
end function
count = Application("ASP_Directory")&Server.MapPath("count.txt")
Set cou = Server.CreateObject("Scripting.FileSystemObject")
Set out = cou.OpenTextFile(count,1,False,False)
Counter = out.ReadLine
out.close
If Session("in") <> "in" Then
Session("in") = "in"
Set out = cou.CreateTextFile(count,True,False)
Application.Lock
Counter = counter + 1 '计数器加1
out.WriteLine(counter) '写入加1后计数器的值
Application.UnLock
out.Close
End If
Response.Write counter
%>
<%
function digital(counter)
dim i,mystr,scounter
scounter=cstr(counter)
for i=1 to 5-len(scounter)
mystr=mystr&"<img src=e:\系统\img\0.gif>"
next
for i=1 to len(scounter)
mystr=mystr&"<img src=e:\系统\img\"& mid(scounter,i,1) &".gif>"
next
digital=mystr
end function
count = Application("ASP_Directory")&Server.MapPath("count.txt")
Set cou = Server.CreateObject("Scripting.FileSystemObject")
Set out = cou.OpenTextFile(count,1,False,False)
Counter = out.ReadLine
out.close
If Session("in") <> "in" Then
Session("in") = "in"
Set out = cou.CreateTextFile(count,True,False)
Application.Lock
Counter = counter + 1 '计数器加1
out.WriteLine(counter) '写入加1后计数器的值
Application.UnLock
out.Close
End If
Response.Write counter
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询