A Java script code that adds a statistic page traffic to a static web page in pure HTML __oracle

Source: Internet
Author: User
Tags setcookie

How to carry on the traffic statistics on the website, can find the third party service website to register, but also can add the code directly on the website, just the following code copy to your webpage, copy to </body> before can. is not very simple AH.

<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 would 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 ("You are the first" + Visits + "bit to visit this topic. ")
-->
</script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.