Can anyone help? I've created a page in Dreamweaver MX and to finish it off I'd like the current date to be displayed. Now, being new to all this Java Stuff, I've found a script for this (see below) but when I add it to the page, the text is too big. So...how can I make the text smaller and maybe change the colour?
Any help, very gratefully received.
Cheers, Dinkiz
</head>
<body>
<script LANGUAGE="JavaScript1.2">
<!-- Begin
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000)
year = year + 1900;
document.write("<center>" + lmonth + " ");
document.write(date + ", " + year + "</center>");// End -->
</script>
</CENTER>
</body>
</html>
Charles
01-19-2003, 06:39 AM
I don't know where you got that piece of Script but whoever wrote it didn't know much about JavaScript. Try this and if you don't like the date format we can adjust that.
document.write('<p style="color:#ff0000; font-size:80%; text-align:center">', new Date(), '<\/p>')
// -->
</script>
Dinkiz
01-19-2003, 06:02 PM
Hi Charles,
I promise you this is the last question (I hope).
What is the best way to insert java into a web page. The reason I ask, is that I've inserted your script, which works wonderfully by the way, but when I insert it, the page looks great when viewed in explorer but in Dreamweaver everything is moved all over the place, which will make it v.v.hard to alter later on.
Any ideas what I can do, if I've done something wrong?
Yours confused,
Dinkiz :confused:
Charles
01-19-2003, 09:30 PM
Do not use Dreamweaver. Use a text editor.
Dinkiz
01-20-2003, 03:48 AM
How do you mean? When I say that everything moves around once I insert the script, I mean that graphics move to the bottom of the page etc....however, it looks normal when viewed in a browser.
Dinkiz :confused:
pyro
01-20-2003, 07:48 AM
You could try inserting Charle's script as an external .js. Make a file called date.js (You can do this in Dreamweaver) and then call it like this where you want the script to appear.
<script language="javascript" src="date.js"></script>This might solve the Dreamweaver problem...
Charles
01-20-2003, 12:55 PM
Do not use the LANGUAGE attribute with the SCRIPT element. It will make Netscape behave in some special, non-complient ways. This is particularly the case with Arrays. Use instead the TYPE attribute.