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 + " 次光临本站,欢迎您的到来!")//这段代码大概意思是检测访问网站的次数,我有很多地方不明白。首先是fixdate()不用行不?似乎在白忙活!第二个问题是settime ()参数中365*....有什么用先问这两个。谢谢啦!!!
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 + " 次光临本站,欢迎您的到来!")//这段代码大概意思是检测访问网站的次数,我有很多地方不明白。首先是fixdate()不用行不?似乎在白忙活!第二个问题是settime ()参数中365*....有什么用先问这两个。谢谢啦!!!
解决方案 »
- jqurey 使用esayui的一个问题 望都来看看
- 将实体标注为@DataTransferObject之后还是不能实现dwr保存form数据
- 为什么我不能得到合计,谢谢大家.....................为什么我不能得到合计
- 如何用js嵌入查询框
- mysql中ALERT问题。在线给分,
- javascript中,怎样把字母转化成ascii码?或把ascii码转化成字母?
- 求正则表达式匹配网页代码中的一部分
- 简单而又复杂
- 如何控制button按钮的大小?
- 请问能否在超链接中 使用 java传出的变量 怎么做?
- 谁有js实现信息提示的代码?
- 请教:javascript如何将地址栏传的参数值接收到呢?
now.getTime() + 365 * 24 * 60 * 60 * 1000前面这些意思就是距今天一年以后的日子。就是设cookie有效时间是1年。
设置cookie的有效期的时间;这样的表达式方便大家看清楚