1.新建count.asp,内部代码如下:
<%
CountFile=Server.MapPath("count.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
Response.Write"document.write("&counter&")"
Out.Close
%>
2.在网站根目录下新建count.txt, 并在文本中写入初始值0.
3.在网站首页需要显示总访问量的地方写入:
总访问量:<script language="JavaScript" src="count.asp";></script>