2012-04-10 80 views
2

我有一个DNN安装,但其中一个门户网站坏了,“注销”按钮似乎并没有清除cokoie。是否有可能使用jQuery来清除特定的cookie?或单独的ASP.NET页面?通过jquery清除cookie?

回答

7

当然,使用cookie plugin这样

$.cookie("name", null); 

更新:

if($('a[href="webiste.co.uk\/en-gb\/admin.aspx"]').length) { 
    $.cookie("name", null); 
} 

更新2:纯的js

function deleteCookie(name) { 
    document.cookie = name+'="";-1; path=/'; 
} 

var login = document.getElementById("loginlink"); 
login.onclick = function() { 
    deleteCookie("name"); 
}; 
+0

jQuery不支持这一点。你正在使用一个jQuery插件。 – 2012-04-10 11:05:56

+0

@FlorianMargaine,正确的 – Starx 2012-04-10 11:06:16

+0

有没有办法检查页面是否包含“Admin”,然后使cookie为空? – 2012-04-10 11:06:23