Forum Moderators: open

Message Too Old, No Replies

Updating Tags and Including Script in Strict XHTML

         

Memphis Steve

11:38 pm on Aug 5, 2007 (gmt 0)

10+ Year Member



I would like to change the font size to exact pixels, change the font face to another gace and also have this script validate in a strict XHTML page. Do I need to update the deprecated HTML tags or should I place the script it in CDATA tag and stay with the old style HTML tags?

Thanks for any help.

<script>

var dayarray=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' face='Arial'>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</font><small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all¦¦document.getElementById)
setInterval("getthedate()",1000)
}

</script>
<span id="clock"></span>

birdbrain

3:16 pm on Aug 6, 2007 (gmt 0)



Hi there Memphis_Steve,

and a warm welcome to these forums. ;)

This is an XHTML 1.0 Strict version, just change the CSS values to suit you taste. :)


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>updated clock</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">
/*<![CDATA[*/
#clock {
font-family:'times new roman',serif;
font-size:24px;
color:#030;
text-align:center;
}
/*//]]>*/
</style>

<script type='text/javascript'>
//<![CDATA[

var dayarray=new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
var montharray=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

function getthedate(){
mydate=new Date();
year=mydate.getUTCFullYear();
day=mydate.getDay();
month=mydate.getMonth();
daym=mydate.getDate();
if(daym<10) {
daym='0'+daym;
}
hours=mydate.getHours();
minutes=mydate.getMinutes();
seconds=mydate.getSeconds();
dn='AM';
if(hours>=12) {
dn='PM';
}
if(hours>12){
hours=hours-12;
}
if(hours==0){
hours=12;
}
if(minutes<=9) {
minutes='0'+minutes;
}
if(seconds<=9) {
seconds='0'+seconds;
}

cdate=dayarray[day]+', '+montharray[month]+' '+daym+', '+year+' '+hours+':'+minutes+':'+seconds+' '+dn;

document.getElementById('clock').firstChild.nodeValue=cdate;

setTimeout('getthedate()',1000);
}
window.onload=function() {
getthedate();
}
//]]>
</script>

</head>
<body>

<div id="clock">&nbsp;</div>

</body>
</html>

birdbrain