//获取指定名称的cookie值
function getCookie(name) {
var result = null;
var myCookie = document.cookie + ";";
var searchName = name + "=";
var startOfCookie = myCookie.indexOf(searchName);
var endOfCookie;
if (startOfCookie != -1) {
startOfCookie += searchName.length;
endOfCookie = myCookie.indexOf(";", startOfCookie);
result = unescape(myCookie.substring(startOfCookie, endOfCookie));
}
return result;
}
//给指定cookie名称赋值
function setCookie(Name, cookievalue) {
var newcookie = Name + "=" + escape(cookievalue);
document.cookie = newcookie;
}
//删除指定名称的cookie
function clearCookie(name) {
var ThreeDays = 3 * 24 * 60 * 60 * 1000;
var expDate = new Date();
expDate.setTime(expDate.getTime() - ThreeDays);
document.cookie = name + "=;expires=" + expDate.toGMTString();
function getCookie(name) {
var result = null;
var myCookie = document.cookie + ";";
var searchName = name + "=";
var startOfCookie = myCookie.indexOf(searchName);
var endOfCookie;
if (startOfCookie != -1) {
startOfCookie += searchName.length;
endOfCookie = myCookie.indexOf(";", startOfCookie);
result = unescape(myCookie.substring(startOfCookie, endOfCookie));
}
return result;
}
//给指定cookie名称赋值
function setCookie(Name, cookievalue) {
var newcookie = Name + "=" + escape(cookievalue);
document.cookie = newcookie;
}
//删除指定名称的cookie
function clearCookie(name) {
var ThreeDays = 3 * 24 * 60 * 60 * 1000;
var expDate = new Date();
expDate.setTime(expDate.getTime() - ThreeDays);
document.cookie = name + "=;expires=" + expDate.toGMTString();
}
//页面关闭自动清除cookie值
function window.onbeforeunload() {
clearCookie("strQues");
}