zoukankan      html  css  js  c++  java
  • 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

    奶奶问孙子:4+1等于几 孙子说:等于6-1。 奶奶说:你明明知道答案,为什么不说? 孙子说:年轻人不讲5的……..
  • 相关阅读:
    洛谷 P2831 [NOIP2016]愤怒的小鸟
    洛谷 P1736 创意吃鱼法
    洛谷 P2347 砝码称重 + bitset简析
    洛谷 P3384 [模板] 树链剖分
    洛谷 P1038 [NOIP2012] 借教室
    洛谷 P3959 [NOIP2017]宝藏 题解
    洛谷 AT2167 Blackout 题解
    洛谷 P1246 编码 题解
    C#中ref关键字的用法总结
    C#中的值传递与引用传递(in、out、ref)
  • 原文地址:https://www.cnblogs.com/jasy/p/12885474.html
Copyright © 2011-2022 走看看