Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<div id="tst" ></div>
<script type="text/javascript">
/*<![CDATA[*/
// Tip of the Day (26=October-2012)
// by Vic Phillips - http://www.vicsjavascripts.org.uk/
function zxcTipOfTheDay(o){
var id=o.ID,tips=o.Tips,now=new Date(),y=now.getFullYear(),m=now.getMonth(),d=now.getDate(),nu=0,c=false,re=new RegExp(id+'='+'[^;]+','i');
if (document.cookie.match(re)){
c=document.cookie.match(re)[0].split("=")[1];
}
if (c){
c=c.split(',');
if (y!=c[0]*1||m!=c[1]*1||d!=c[2]*1){
nu=++c[3]%tips.length;
}
}
document.getElementById(id).innerHTML=tips[nu];
document.cookie=id+'='+y+','+m+','+d+','+nu+';expires='+(new Date(new Date().getTime()+864000000).toGMTString())+';path=/';
}
zxcTipOfTheDay({
ID:'tst',
Tips:[
'Tip 1',
'Tip 2',
'Tip 3',
'Tip 4',
'Tip 5'
]
});
/*]]>*/
</script>
</body>
</html>
simpler
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<div id="tst" ></div>
<script type="text/javascript">
/*<![CDATA[*/
// Tip of the Day (26=October-2012)
// by Vic Phillips - http://www.vicsjavascripts.org.uk/
function zxcTipOfTheDay(o){
var id=o.ID,tips=o.Tips,now=Math.floor(new Date().getTime()/86400000),nu=0,c=false,re=new RegExp(id+'='+'[^;]+','i');
if (document.cookie.match(re)){
c=document.cookie.match(re)[0].split("=")[1].split(',');
if (now-c[0]>0){
nu=++c[1]%tips.length;
}
}
document.getElementById(id).innerHTML=tips[nu];
document.cookie=id+'='+now+','+nu+';expires='+(new Date(new Date().getTime()+864000000).toGMTString())+';path=/';
}
zxcTipOfTheDay({
ID:'tst',
Tips:[
'Tip 1',
'Tip 2',
'Tip 3',
'Tip 4',
'Tip 5'
]
});
/*]]>*/
</script>
</body>
</html>
Bookmarks