Это то, что я думаю Вы хотите:
var Response = {};
Response.Cookie =
function() {
var self = this;
Cookies = {};
this.Cookies = document.cookie;
this.Cookies = this.Cookies.replace(/([^=]+)=([^;]+);?/g,
function(foo, label, value) {
Cookies[label] = value;
});
this.Cookies = Cookies;
};
Response.Cookie();
for(var cookie in Response.Cookies){
alert(cookie + ' = ' +Response.Cookies[cookie])
}
Fiddle: http://jsfiddle.net/maniator/Yb8NK/
ОБНОВЛЕНИЕ:
Этоверсия без вызова Response.Cookie()
: http://jsfiddle.net/maniator/Yb8NK/25/
var Response = {
Cookies: null
}
Response.Cookie = (function() {
var self = Response;
Cookies = {};
self.Cookies = document.cookie;
self.Cookies = self.Cookies.replace(/([^=]+)=([^;]+);?/g,
function(foo, label, value) {
Cookies[label] = value;
});
self.Cookies = Cookies;
})();
for (var cookie in Response.Cookies) {
alert(cookie + ' = ' + Response.Cookies[cookie])
}
ОБНОВЛЕНИЕ № 2:
Еще лучшая версия:
var Response = {};
Response.Cookies = (function() {
var cookies = {};
var doc_cookies = document.cookie;
doc_cookies = doc_cookies.replace(/([^=]+)=([^;]+);?/g,
function(foo, label, value) {
cookies[label] = value;
});
return cookies;
})();
for (var cookie in Response.Cookies) {
alert(cookie + ' = ' + Response.Cookies[cookie])
}
Fiddle:http://jsfiddle.net/maniator/Yb8NK/29/