本文实例讲述了Java脚本语言统计网站访问次数的实现代码。分享给大家供大家参考。具体如下:运行效果截图如下:
完整代码:
html头元http-equiv=' Content-Type ' Content=' text/html;charset=GB 2312 ' title new Page 5/title meta name=' GENERATOR ' content=' Microsoft front Page 3.0 '脚本语言='JavaScript '!-var警告=假函数setCookie(名称、值、过期、路径、域、安全){ var curCookie=name '=' escape(值)((过期)?expires=' expires。togtstring()' : ' ')((路径)?path=' path : ' ')(域)?网域='网域: ' ')((安全)?secure' : '') if(!小心||(名称=' escape(value)).长度=4000)文档。cookie=cur ookie else if(确认(' Cookie超过4KB,将被剪切!))document.cookie=curCookie }函数getCookie(名称){ var前缀=name '=' var cookieStartIndex=document。饼干。indexof(前缀)if (cookieStartIndex==-1)返回null var cookieEndIndex=document。饼干。indexof(';cookieStartIndex前缀。length)if(cookieEndIndex==-1)cookieEndIndex=document。饼干。长度返回unescape(文档。饼干。子字符串(cookieStartIndex前缀。长度,cookieEndIndex)) }函数删除Cookie(名称、路径、域){ if (getCookie(名称)){ document.cookie=name '=' ((路径)?path=' path : ' ')(域)?domain=' domain : ' ')';到期时间=01年1月1日星期四至70日00:000336001 '格林尼治时间} }函数固定日期(日期){ var基数=新日期(0)var偏斜=基数。如果(偏斜0)日期,则获取时间()。设置时间(日期。gettime()-skew)} var now=new Date()fix Date(now)now。设置时间(现在。gettime()730 * 24 * 60 * 60 * 1000)var visitors=getCookie(' counter ')if(!访问量)访问量=1否则访问量=parseInt(访问量)1个setCookie('计数器',访问量,现在)文档。书写('字体大小=6色=红色欢迎您,您是第:"访问"个访问该站点的访客)/////脚本/头体p align=' right '/p/body/html以上就是为大家分享的Java脚本语言统计网站访问次数的实现代码,希望对大家的学习有所帮助。