It may work for you now, but how about someone in China, or Mexico? Or how about when you have other scripts or objects on your page that might conflict with the undeclared globals in the code? This is much better:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>future planning</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#info {
width:20em;
line-height:2em;
border:0.2em double #33c;
font-family:verdana,arial,helvetica,sans-serif;
font-size:1em;
color:#006;
text-align:center;
background-color:#ccf;
margin:1.6em auto;
}
</style>
<script type="text/javascript">
window.onload=function() {
/*************************************************************
start will generate the day of the week.
So 1 will set it for Monday and 7 will set it for Sunday.
*************************************************************/
var
now=new Date(),
yy=now.getFullYear(),
mm=now.getMonth(),
dd=now.getDate(),
start=new Date(2007,0,2), /* this will produce a Tuesday date add ifinitum */
days=Math.floor((now-start)/(1000*60*60*24)),
months=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
dd=dd+(7-(days % 7)); /* dd-(days % 7);would be this weeks Tuesday */
var next=months[mm] +' '+ dd +', '+ yy;
document.getElementById('info').firstChild.nodeValue='Next Tuesday is '+next+'.';
}
</script>
</head>
<body>
<div id="info"> </div>
</body></html>
Bookmarks