2012-11-05 57 views

回答

2

你可以直接從你從getAll()得到的信息的網址:

var cookie; // one single cookie from the array 

var url = ''; 
// get prefix, like https://www. 
url += cookie.secure ? 'https://' : 'http://'; 
url += cookie.domain.charAt(0) == '.' ? 'www' : ''; 

// append domain and path 
url += cookie.domain; 
url += cookie.path; 

console.log(url); // something like "https://www.stackoverflow.com/" 
1

屬性爲您提供了與Cookie關聯的域。並且路徑爲您提供該域內的路徑。來自Cookie API Test Extension

function removeCookie(cookie) { 
    var url = "http" + (cookie.secure ? "s" : "") + "://" + cookie.domain + 
      cookie.path; 
    chrome.cookies.remove({"url": url, "name": cookie.name}); 
} 
相關問題