问题描述
嗨我有一个在我们服务器上托管的网站的点击计数器。我每次网站点击时都使用vb脚本写入文本文件。它是使用iis托管的本地网站。问题是,当从服务器的浏览器打开网站时,它只将匹配写入文本文件。如果网站在另一台计算机上打开,它不会写入文本文件的命中。我已将iis权限授予共享驱动器上的文本文件。
hi i have a hit counter for a website hosted on our server. i am using vb script to write to text file each time the website has a hit. it is a local website hosted using iis. the problem is that it only writes the hits to the textfile when the website is opened from the server''s brower. if the website is opened on another computer, it does not write hits to the text file. I have granted iis permissions to the text file which is on a shared drive.
<font color="#FFFFFF"><b>Total Site Hits:</b>
<SCRIPT type=text/vbscript>
Dim fso
Dim tso
Dim filObject
Dim VisitorCount
Dim strOutputName
Dim objOutputFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set filObject = fso.GetFile("\\cci-opsweb01\TTHitCount\HitCounter.txt")
Set tso = filObject.OpenAsTextStream
VisitorCount = CLng(tso.ReadAll)
VisitorCount = VisitorCount + 1
strOutputName = "\\cci-opsweb01\TTHitCount\HitCounter.txt"
Set objOutputFile = fso.createTextFile(strOutputName,True)
objOutputFile.WriteLine VisitorCount
Document.Write(VisitorCount)
</Script>
推荐答案
在网站打开时将匹配写入文本文件服务器的浏览器。如果网站在另一台计算机上打开,它不会写入文本文件
writes the hits to the textfile when the website is opened from the server''s brower. if the website is opened on another computer, it does not write hits to the text file
那是因为你写的是
That is because you are writing to
\\cci-opsweb01 \TTHitCount \HitCounter.txt
"\\cci-opsweb01\TTHitCount\HitCounter.txt"
存在于服务器上而不是客户端打开浏览器的机器上代码被执行。请记住,脚本是在使用您的URL打开浏览器的机器上执行的。
如果您希望在服务器上更新点击计数器,则需要将点击发布到服务器。
[]
[]
[]
[]
或者更确切地说使用互联网上提供的免费点击计数器。例如www.statcounter.com
which exists on the server and not on the client''s machine where the browser is opened and the code is executed. Remeber that the script is executed on the machine where the browser is opened with your URL.
If you want the hit counter to be updated on the server, you need to post the ''hit'' to the server.
http://helpingdotnet.blogspot.com/2011/10/page-hit-counter-using-application-in.html[^]
http://magwebonline.blogspot.com/2013/01/create-page-hit-counter-in-aspnet.html[^]
http://www.codingasp.net/2011/09/unique-visiter-counter-in-aspnet.html[^]
http://highoncoding.com/Articles/78_Implementing_Hit_Counter_in_Asp_net.aspx[^]
Or rather use the free hit counters available on the internet . e.g www.statcounter.com
这篇关于html使用vb脚本点击计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!