Click to See Complete Forum and Search --> : Font colours


dcjones
10-10-2003, 06:22 AM
Hi All,

This is a simple one but I am having problems with it.

I need to add the current date to a HTML page. I am using the following script. It works BUT how do I change the colour of trhe OUTPUT. It is currently showing in black. Any help would be good.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Dynamic Date Display</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers

dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")

now = new Date

// End hiding script from old browsers -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="WHITE">
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers

document.write("<H1><TD font color='#0252C3'>Today is " + dayName[now.getDay()] + ", " + monName[now.getMonth()] + " " + now.getDate() + ".</TD><\/H1> ")

// End hiding script from old browsers -->
</SCRIPT>
</BODY>
</HTML>

Regards and thanks in advance for any help you can give.

Dereck

dcjones
10-10-2003, 06:24 AM
Correct Script

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Dynamic Date Display</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers

dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")

now = new Date

// End hiding script from old browsers -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="WHITE">
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers

document.write("<H1>Today is " + dayName[now.getDay()] + ", " + monName[now.getMonth()] + " " + now.getDate() + ".<\/H1> ")

// End hiding script from old browsers -->
</SCRIPT>
</BODY>
</HTML>

Thanks

Charles
10-10-2003, 07:25 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>

<style type="text/css">
<!--
p#date {color:#a00; font-size:200%; font-weight:bold}
-->
</style>

<script type="text/javascript">
<!--
Date.prototype.toDateString = function () {return [['Sunday,', 'Monday,', 'Tuesday,', 'Wednesday,', 'Thursday,', 'Friday,', 'Saturday,'] [this.getDay()], this.getDate(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] [this.getMonth()], this.getFullYear()].join('&nbsp;')}
// -->
</script>

<h1>Example</h1>

<script type="text/javascript">
<!--
document.write ('<p id="date">Today is ', new Date().toDateString(), '.</p>');
// -->
</script>

H1 does not mean "big and bold", it means "level one heading" which is to say the title.

dcjones
10-10-2003, 07:35 AM
Hi Charles,

Thanks for that

Regards

Dereck

Keep safe and well

dcjones
10-10-2003, 08:31 AM
Hi Charles,

I have used the script you kindly posted and it works fine.

But, when I copy it to my HTML page it still works but shows the date as

Fri Oct 10 2993

What causes this to happen

Many Thanks

Dereck

jbergthorson
10-10-2003, 10:02 AM
you sure someone didn't change the date on your computer to 2993 instead of 2003? Works on my computer here.

dcjones
10-10-2003, 10:13 AM
Hi All SORRY

Typo-Error

The date that is showing in my html page is

Fri 10 Oct 2003

If I use the same script on a new page is shows as

Friday 10 October 2003

Can anyone help

Regards

Dereck

Charles
10-10-2003, 11:58 AM
You will notice that my example employs two SCRIPT blocks. The first block overwrites the native Date.toDateString() method which is locale dependant. The second block uses this method. Something that you have done is causing the first block to not run.