Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<div> tag troubles

Status
Not open for further replies.

drgenius

Programmer
Oct 14, 2001
46
0
0
NL
Hi, can anybody please tell me what's wrong with this code? The part I'm interested in is where text is being put between the div-tags. I get the error message that document.htmlClock is undefined or not an object. I got this example straight out of a magazine but it just doesn't work :-( I tried both IE 5.5 and Opera 6.

Code:
<html>
<head>
<title></title>

<script language=&quot;javaScript&quot;>
<!--
 
function doClock(){
	today = new Date();
	document.htmlClock.innerText = today.getHours() + 'u' + today.getMinutes() + 'm' + today.getSeconds();
	setTimeout('doClock()', 1000);
}
 
//-->
</script>

</head>
<body onLoad=&quot;doClock();&quot;>

<div id=&quot;htmlClock&quot;></div>

</body>
</html>
It's not a lie if YOU believe it ;-)
 
Never mind, I already figured it out myself. The right way to address the div element is
Code:
htmlClock.innerText
and it only works in IE, not in Opera. It's not a lie if YOU believe it ;-)
 
try removing the reference to document

Example:

function doClock(){
today = new Date();
htmlClock.innerText = today.getHours() + 'u' + today.getMinutes() + 'm' + today.getSeconds();
setTimeout('doClock()', 1000);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top