jscheuer1
06-08-2013, 03:02 AM
1) Script Title: Drop-in content box v2.0
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/dropinbox.htm
3) Describe problem: Session only cookie does not work in IE 8 and less. Here's an updated version of the script which corrects that:
5083
Only the set cookie function is changed. It's changed to assure that one of the persistent modes is in play (day, hr or min) before attempting to calculate an expiration date:
dropincontentbox.routines={
cookiere: /^(\d+)(day|hr|min)$/, //re to parse duration if not 'session' -jds
getCookie:function(Name){
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return null
},
setCookie:function(name, value, duration){
var expirestr='', expiredate=new Date()
if (typeof duration!=="undefined" && (duration=dropincontentbox.routines.cookiere.exec(duration))){ //if set persistent cookie and not session -jds
var offsetmin=duration[1] * (duration[2]==='hr'? 60 : duration[2]==='day'? 60*24 : 1)
expiredate.setMinutes(expiredate.getMinutes() + offsetmin)
expirestr="; expires=" + expiredate.toUTCString()
}
document.cookie = name+"="+value+"; path=/"+expirestr
}
}
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/dropinbox.htm
3) Describe problem: Session only cookie does not work in IE 8 and less. Here's an updated version of the script which corrects that:
5083
Only the set cookie function is changed. It's changed to assure that one of the persistent modes is in play (day, hr or min) before attempting to calculate an expiration date:
dropincontentbox.routines={
cookiere: /^(\d+)(day|hr|min)$/, //re to parse duration if not 'session' -jds
getCookie:function(Name){
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return null
},
setCookie:function(name, value, duration){
var expirestr='', expiredate=new Date()
if (typeof duration!=="undefined" && (duration=dropincontentbox.routines.cookiere.exec(duration))){ //if set persistent cookie and not session -jds
var offsetmin=duration[1] * (duration[2]==='hr'? 60 : duration[2]==='day'? 60*24 : 1)
expiredate.setMinutes(expiredate.getMinutes() + offsetmin)
expirestr="; expires=" + expiredate.toUTCString()
}
document.cookie = name+"="+value+"; path=/"+expirestr
}
}