js 显示网站当前访客是几位访客

Posted 路漫漫其修远兮,吾将上下而求索

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js 显示网站当前访客是几位访客相关的知识,希望对你有一定的参考价值。

<SCRIPT language=javascript>

<!--

var caution = false

function setCookie(name, value, expires, path, domain, secure) {

var curCookie = name + "=" + escape(value) +

((expires) ? "; expires=" + expires.toGMTString() : "") +

((path) ? "; path=" + path : "") +

((domain) ? "; domain=" + domain : "") +

((secure) ? "; secure" : "")

if (!caution || (name + "=" + escape(value)).length <= 4000)

document.cookie = curCookie

else

if (confirm("Cookie exceeds 4KB and will be cut!"))

document.cookie = curCookie

}

function getCookie(name) {

var prefix = name + "="

var cookieStartIndex = document.cookie.indexOf(prefix)

if (cookieStartIndex == -1)

return null

var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)

if (cookieEndIndex == -1)

cookieEndIndex = document.cookie.length

return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))

}

function deleteCookie(name, path, domain) {

if (getCookie(name)) {

document.cookie = name + "=" +

((path) ? "; path=" + path : "") +

((domain) ? "; domain=" + domain : "") +

"; expires=Thu, 01-Jan-70 00:00:01 GMT"

}

}

function fixDate(date) {

var base = new Date(0)

var skew = base.getTime()

if (skew > 0)

date.setTime(date.getTime() - skew)

}

var now = new Date()

fixDate(now)

now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)

var visits = getCookie("counter")

if (!visits)

visits = 1

else

visits = parseInt(visits) + 1

setCookie("counter", visits, now)

document.write("欢迎光临本站,您是第" + visits + "位访问者!")

// -->

</SCRIPT>

 

js 显示网站当前访客是几位访客 - 百度文库 https://wenku.baidu.com/view/4fc24563f90f76c661371aad.html

以上是关于js 显示网站当前访客是几位访客的主要内容,如果未能解决你的问题,请参考以下文章

打印访客当前日期[重复]

网站如何添加访客统计代码

piwik 访客跟踪

XSS结合JSONP获取网站访客社交账号信息

多说最近访客JS插件通用代码使用方法

如何创建默认的“访客”会话,以便设计助手 current_user 显示我的访客用户?