统计网页访问次数

 
  1. <script language="JavaScript">
  2. <!-- 
  3. var caution = false
  4. function setCookie(name, value, expires, path, domain, secure) {
  5.         var curCookie = name + "=" + escape(value) +
  6.                 ((expires) ? "; expires=" + expires.toGMTString() : "") +
  7.                 ((path) ? "; path=" + path : "") +
  8.                 ((domain) ? "; domain=" + domain : "") +
  9.                 ((secure) ? "; secure" : "")
  10.         if (!caution || (name + "=" + escape(value)).length <= 4000)
  11.                 document.cookie = curCookie
  12.         else
  13.                 if (confirm("Cookie exceeds 4KB and will be cut!"))
  14.                         document.cookie = curCookie
  15. }
  16. function getCookie(name) {
  17.         var prefix = name + "="
  18.         var cookieStartIndex = document.cookie.indexOf(prefix)
  19.         if (cookieStartIndex == -1)
  20.                 return null
  21.         var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
  22.         if (cookieEndIndex == -1)
  23.                 cookieEndIndex = document.cookie.length
  24.         return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
  25. }
  26. function deleteCookie(name, path, domain) {
  27.         if (getCookie(name)) {
  28.                 document.cookie = name + "=" + 
  29.                 ((path) ? "; path=" + path : "") +
  30.                 ((domain) ? "; domain=" + domain : "") +
  31.                 "; expires=Thu, 01-Jan-70 00:00:01 GMT"
  32.         }
  33. }
  34. function fixDate(date) {
  35.         var base = new Date(0)
  36.         var skew = base.getTime()
  37.         if (skew > 0)
  38.                 date.setTime(date.getTime() - skew)
  39. }
  40. var now = new Date()
  41. fixDate(now)
  42. now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)
  43. var visits = getCookie("counter")
  44. if (!visits)
  45.         visits = 1
  46. else
  47.         visits = parseInt(visits) + 1
  48. setCookie("counter", visits, now)
  49. document.write("2259欢迎您的第" + visits + "次光临!")
  50. // -->
  51. </script>
  52. <a href="http://www.alixixi.com/Dev/HTML/jsrun/">欢迎访问阿里西西网页特效集</a>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值