建站代码网

热门标签

计数的点击(不用db)

需要跟踪你的用户在哪儿点击你的网站吗?计数和显示没有数据库的网站的计数数量是很容易的。下面的例子会利用到3种需要输入读取服务器上的文本文件加一个该值和将其写回到服务器的相同的文档(linka.asp.linkb.asp.linkc.asp)and click counter.asp

linka.asp, linkb.asp, linkc.asp <% set fso = createobject("scripting.filesystemobject") set act = fso.opentextfile(server.mappath("linka.txt")) counter = clng(act.readline) act.close %> <a href="click_counter.asp?u_link=linka.asp">link A</a> (<%= counter %> clicks) <br> <% set act = fso.opentextfile(server.mappath("linkb.txt")) counter = clng(act.readline) act.close %> <a href="click_counter.asp?u_link=linkb.asp">link B</a> (<%= counter %> clicks) <br> <% set act = fso.opentextfile(server.mappath("linkc.txt")) counter = clng(act.readline) act.close %> <a href="click_counter.asp?u_link=linkc.asp">link C</a> (<%= counter %> clicks) click_counter.asp <% u_link=request.querystring("u_link") counter_add= replace(u_link,".asp",".txt") set fso = createobject("scripting.filesystemobject") set act = fso.opentextfile(server.mappath(counter_add)) counter = clng(act.readline) act.close counter = counter + 1 Set act = fso.CreateTextFile(server.mappath(counter_add), true) act.WriteLine(counter) act.Close response.redirect (u_link) %>