在FF和Chrome中设置cookie工作属性但在IE中不起作用
function setCookie(key, value) {
var expires = new Date();
expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
document.cookie = key + '=' + value +';path=/'+ ';expires=' + expires.toUTCString();
}
function checkCookie()
{
var newsletter=getCookie("newsletter5");
if (newsletter!=null && newsletter!="")
{
}
else
{
setCookie("newsletter5", 2000);
timeMsg();
}
}
setCookie("newsletter5", 2000);
当我降低安全保护低于平均值时,它可以正常工作,但它应该在默认设置下工作
答案 0 :(得分:0)
在浏览器中启用Cookie和JavaScript
答案 1 :(得分:0)
setCookie("name","value",expiryDate,"/");
// cookie.js file
var cookieToday = new Date();
var expiryDate = new Date(cookieToday.getTime() +
(365 *86400000)); // a year
/* Cookie functions originally by Bill Dortsch */
function setCookie (name,value,expires,path,theDomain,secure) {
value = escape(value);
var theCookie = name + "=" + value +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((theDomain) ? "; domain=" + theDomain : "") +
((secure) ? "; secure" : "");
document.cookie = theCookie;
}
function getCookie(Name) {
var search = Name + "="
if (document.cookie.length > 0) { // if there are any cookies
var offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
var end = document.cookie.indexOf(";", offset)
// set index of end of cookie value
if (end == -1) end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
}
}
}
function delCookie(name,path,domain) {
if (getCookie(name)) document.cookie = name + "=" +
((path) ? ";path=" + path : "") +
((domain) ? ";domain=" + domain : "") +
";expires=Thu, 01-Jan-70 00:00:01 GMT";
}
答案 2 :(得分:0)
我认为主要问题是将值设置为document.cookie
当我设置一些值并且检查IE时没有被签名。