我绝对无法弄清楚这段代码有什么问题,
第一次迭代完美无缺:
if (window.location.href != "http://fiddlehead.co/pages/verify-age") {
current_url = window.location;
document.cookie = 'landing_Cookie=' + escape(current_url) +';'
};
但是我需要cookie在几秒钟内过期而且这不起作用(没有创建cookie):
if (window.location.href != "http://fiddlehead.co/pages/verify-age") {
function createCookie(name, value) {
var date = new Date();
date.setTime(date.getTime()+(30*1000));
var expires = "; expires="+date.toGMTString();
var current_url = window.location;
document.cookie = name+"="+escape(value)+expires+"; path=/";
};
createCookie('landing_Cookie', current_url);
};
任何帮助都会非常感激,这是几个小时敲打桌子的最后一道障碍!
答案 0 :(得分:1)
var current_url = window.location;
必须放在createCookie
的正文之外。