⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 6-11.asp

📁 《动态网页设计基础教程》,胡杰,科学出版社
💻 ASP
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>
<%	
Dim Visitors
WhichFile=Server.mappath("count.txt")

'创建一个FileSystemObject的实例
Set fs=Server.CreateObject("Scripting.FileSystemObject")
'启动count.txt文件,并且读取记录在文件中的Visitors
Set thisfile=fs.OpenTextFile(WhichFile,,TRUE)
Visitors=thisfile.ReadLine
Thisfile.close
If IsEmpty(session("Connected")) Then
'将计数器加1
Visitors=Visitors+1
End If
Session("connected")=True
'将计数器写入count.txt文件之中
Set out=fs. CreateTextFile(WhichFile)
Out.WriteLine(Visitors)
Out.close
Set fs=nothing
%>
<CENTER><H2>欢迎进入Myweb网站</h2>
<HR>
您是本站第<%=visitors%>位贵宾</center>
<p>
<!--
其原理是设置一个Session变量“Session(“connected”)”作为标记,验证当前的用户是否改变,如果已经改变着执行计数值的增加,否则计数值不变,最后将“Session(“connectde”)”赋值为True,表明该用户已经访问过此页面,不能再通过刷新来增加计数值。
-->
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -