记录来访者次数的特效
[ 来源: | 作者: | 更新日期:2008-4-30 23:41:38 |
评论 0 条 |
我要投稿 ]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 字串6
<title>记住每个来访者的次数</title>
<script language="JavaScript"> 字串4
<!--
var caution = false 字串4
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) + 字串5
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") + 字串4
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "") 字串1
if (!caution || (name + "=" + escape(value)).length <= 4000)
document.cookie = curCookie 字串8
else
if (confirm("Cookie exceeds 4KB and will be cut!")) 字串5
document.cookie = curCookie
} 字串4
function getCookie(name) {
var prefix = name + "=" 字串3
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1) 字串7
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length) 字串4
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length 字串2
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
} 字串3
function deleteCookie(name, path, domain) {
if (getCookie(name)) { 字串9
document.cookie = name + "=" +
((path) ? "; path=" + path : "") + 字串1
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT" 字串5
}
} 字串5
function fixDate(date) {
var base = new Date(0) 字串6
var skew = base.getTime()
if (skew > 0) 字串5
date.setTime(date.getTime() - skew)
} 字串3
var now = new Date()
fixDate(now) 字串3
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)
var visits = getCookie("counter") 字串1
if (!visits)
visits = 1 字串2
else
visits = parseInt(visits) + 1 字串4
setCookie("counter", visits, now)
document.write("欢迎您第 " + visits + " 次来到本站点") 字串6
// -->
</script> 字串9
</head>
<body> 字串3
<p></p> 字串6
<p></p>
字串6
</body>
</html>
Tags:特效 次数 来访 记录 var name domain path visits if