簡単なウェブサイトのアクセスJSカウンタの更新は1回に1回追加されます.
2598 ワード
<br><!--
<br>var caution = false
<br>function setCookie(name, value, expires, path, domain, secure) {
<br> var curCookie = name + "=" + escape(value) +
<br> ((expires) ? "; expires=" + expires.toGMTString() : "") +
<br> ((path) ? "; path=" + path : "") +
<br> ((domain) ? "; domain=" + domain : "") +
<br> ((secure) ? "; secure" : "")
<br> if (!caution || (name + "=" + escape(value)).length <= 4000)
<br> document.cookie = curCookie
<br> else
<br> if (confirm("Cookie exceeds 4KB and will be cut!"))
<br> document.cookie = curCookie
<br>}
<br>function getCookie(name) {
<br> var prefix = name + "="
<br> var cookieStartIndex = document.cookie.indexOf(prefix)
<br> if (cookieStartIndex == -1)
<br> return null
<br> var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
<br> if (cookieEndIndex == -1)
<br> cookieEndIndex = document.cookie.length
<br> return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
<br>}
<br>function deleteCookie(name, path, domain) {
<br> if (getCookie(name)) {
<br> document.cookie = name + "=" +
<br> ((path) ? "; path=" + path : "") +
<br> ((domain) ? "; domain=" + domain : "") +
<br> "; expires=Thu, 01-Jan-70 00:00:01 GMT"
<br> }
<br>}
<br>function fixDate(date) {
<br> var base = new Date(0)
<br> var skew = base.getTime()
<br> if (skew > 0)
<br> date.setTime(date.getTime() - skew)
<br>}
<br>var now = new Date()
<br>fixDate(now)
<br>now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)
<br>var visits = getCookie("counter")
<br>if (!visits)
<br> visits = 1
<br>else
<br> visits = parseInt(visits) + 1
<br>setCookie("counter", visits, now)
<br>document.write(" " + visits + " !")
<br>// -->
<br>