📄 0094.htm
字号:
<html>
<head>
<title>新时代软件教程:操作系统 主页制作 服务器 设计软件 网络技术 编程语言 文字编辑</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
body, table {font-size: 9pt; font-family: 宋体}
a {text-decoration:none}
a:hover {color: red;text-decoration:underline}
.1 {background-color: rgb(245,245,245)}
-->
</style>
</head>
<p align="center"><script src="../../1.js"></script></a>
<p align="center"><big><strong>续用ASP编写计数器</strong></big></p>
<span class="text">《 用ASP编写计数器
》一文,详细的说明了如何利用流行的ASP来编写计数器,该文通过使Application.Lock和Applicaiotn.Unlock解决了多用户同时访问站点,计数器只能加1的问题,但是,如果某个用户,反复点击“刷新”按钮,那么计数器还是要不断的增加的,这样对于网站点击率评比来说是不公平的。<br>
要防止上网用户连续按下“刷新”,最好的办法就是利用ASP的Session对象,我们可以借助Session对象首先判断该用户是否为新连接者,如果是,那么<br>
IsEmpty(Session("hasbeenConnected"))=True,也就是说,Session("hasbeenConnected")是空的。那么,运行程序,使计数器加1,然后将该用户的Session("hasbeenConnected")设置为True,也就是说,这个用户已经不是新的连接者,无论他怎么连续按下“刷新”按钮,计数器也不会再增加。<br>
结合《 用ASP编写计数器 》一文,最后的站点计数器count.asp程序应该是:<br>
<br>
<%<br>
If IsEmpty(Session("hasbeenConnected")) then <br>
Application.Lock<br>
Application("number")=Application("number")+1<br>
Applicaiotn.Unlock<br>
response.Write("你是第"&number&"位访问者!")<br>
End If<br>
Session("hasbeenConnected")=True<br>
%></span>
</table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -