guitardave78
Programmer
Hi all. I have been writing some javascript stuff using the following style. I picked it up somwhere and it is very much like classes in vbscript. Can anyone tell me what it is called so i can research it a bit more!!
}...the bane of my life!
Code:
var cookie = {
set : function(name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate);
},
get : function(name){
if (document.cookie.length>0){
var cookies = document.cookie
cookies = cookies.split(";")
for(var n=0;n<cookies.length;n++){
var namePos = cookies[n].indexOf(name.toLowerCase() + "=");
if(namePos >= 0){
var value = cookies[n].split("=")[1]
value = value.replace(/\+/g, ' ');
return(unescape(value));
break;
}
}
}
return null
},
remove : function(name){
cookie.set(name,null,-1);
}
}
}...the bane of my life!