【发布时间】:2015-03-21 12:08:03
【问题描述】:
当用户单击某个链接以在下一页中提供“返回”链接时,我想将当前页面记录在 cookie 中。顺便说一句,我不在 asp.net 中使用页面 Request.UrlReferrer,因为用户可能会在打开的新页面中进行分页,但推荐 URL 不得更改。这是我的代码:
$('.options a').click(function (e) {
var a = $(this);
$.cookie('return-to', a.attr('href') + '#' + a.closest('.names').attr('id'), {expires:1});
e.preventDefault();
document.location.href = a.attr('href');
});
上面的代码没有设置cookie,但是这个设置了:
$('.options a').click(function (e) {
var a = $(this);
$.cookie('return-to', a.attr('href') + '#' + a.closest('.names').attr('id'), {expires:1});
e.preventDefault();
// document.location.href = a.attr('href');
});
为什么设置 document.location.href 会阻止设置 cookie?
【问题讨论】:
标签: javascript jquery asp.net cookies