wrote:
> Hi, one part of my website is at:
>
> http://www.psych.nmsu.edu/~jkroger/lab/undergrads.html
>
>
>
> I want to make the date at the top right darker blue.
> But when I do that, all the light blue text next to
> the pictures also changes.
>
> How can I control the color of the result of
> document.write output without changing the
> forground color of the entire page? Note my
Wrap it in a <span> with the appropriate colour. Your
"get date" function is a bit rough too, suggested
improvement below.
Using arrays for months and days is considerably more
efficient than your multiple if's.
> document write includes variables, so I was
> hesitant to imbed an html command in the
> document.write.
HTML is not "commands", it is markup that is interpreted.
It may seem a trivial point, but there you go. You have
no other way of controlling the colour of the element
than using markup, so use it. I have used a span and style,
but you could use a class too.
<html>
<head>
<title>play</title>
<script type="text/javascript">
function clientDate(){
var months = ['January','February','March',
'April','May','June','July',
'August','September','October',
'November','','December'];
var days = ['Sunday','Monday','Tuesday',
'Wednesday','Thursday','Friday',
'Saturday'];
var now = new Date();
return days[now.getDay()]
+ ', ' + months[now.getMonth()]
+ ' ' + now.getDate()
+ ', ' + now.getFullYear();
}
</script>
</head>
<body>
<script type="text/javascript">
document.write('<span style="color: #333366">' +
clientDate() + '</span>');
</script>
</body>
</html>
--
Rob