我的cookie工作正常我沒有提及日期,所以當瀏覽器窗口關閉時,cookie被刪除。如何刪除選項卡上的jQuery Cookie關閉
,但是當我在瀏覽器窗口中的cookie不會被刪除,關閉選項卡,打開相同的保存Cookie狀態頁面當我打開網站
當用戶關閉瀏覽器選項卡如何刪除Cookie?
下面是我的代碼
$(document).ready(function(){
var href = $.cookie("activeElementHref");
if(href!==null)
{
setContainerHtml(href);
};
$('nav ul li a').click(function(e){
e.preventDefault();
href= $(this).attr('href');
$.cookie("activeElementHref", href)
setContainerHtml(href);
});
});
$(window).unload(function() {
$.cookies("activeElementHref",null);
});
function setContainerHtml(href) {
$.ajax({
type: "POST",
url: "baker.php",
data:{send_txt: href},
success: function(data){
$('#aside-right, #intro').css('display','none');
$('#main-content').fadeOut('10', function(){
$('#main-content').css('width','700px');
$('#main-content').css('margin','-30px 0 0 100px');
$('#main-content').html(data);
$('#main-content').fadeIn('8000');
});
}
});
}
的可能重複:http://stackoverflow.com/questions/805895/how-come-closing-a-tab-doesnt-close-a-session-cookie – 2012-02-06 09:31:53
你有沒有發現一個解決方案?我有同樣的問題,我只需要在選項卡關閉刪除cookie,而不是頁面刷新 – Jeff 2016-05-25 14:06:05