Jump to content

Javascript clock


littleMe

Recommended Posts

i have tryed to validate this code ( at validator.w3.org) many times and everytime i get this error. can anybody tell me what i have to change to get it to work? 1. Error Line 80 column 14: document type does not allow element "SPAN" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag. <span id="txt"> </span> The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element. One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"	 "http://www.w3.org/TR/html4/strict.dtd">   <html>		<head>		<title> bunn		</title></head><body onload="startTime()">		<script type="text/javascript"><!--// Get today's current date.var now = new Date();// Array list of days.var days = new Array('Søndag','Mandag','Tirsdag','Onsdag','Torsdag','Fredag','Lørdag');// Array list of months.var months = new Array('Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember');// Calculate the number of the current day in the week.var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();// Calculate four digit year.function fourdigits(number)	{	return (number < 1000) ? number + 1900 : number;								}// Join it all togethertoday =  days[now.getDay()] + " " +			   date + ". " +			   months[now.getMonth()] + " " +				(fourdigits(now.getYear()));// Print out the datadocument.write("Lokal tid: " +today+ " ");document.write("kl.");//  End --></script><script type="text/javascript">		<!--		function startTime()		{		var today=new Date()		var h=today.getHours()		var m=today.getMinutes()		var s=today.getSeconds()		// add a zero in front of numbers<10		var siffer = "";		if( h < 10 ) {		siffer = "0"		}		m=checkTime(m)		s=checkTime(s)		document.getElementById("txt").innerHTML= siffer + h +":"+m+":"+s		t=setTimeout('startTime()',500)		}		function checkTime(i)		{		if (i<10)		  {i="0" + i}		  return i		}		//-->		</script><span id="txt"> </span></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...