| re: Help convert code from IE to Mozilla
It's the same sort of problem, in that IE exposes the id's at the top level
(which is not part of the DOM standard):
setInterval("GetTime(document.getElementById('" + TimeAnchor.id + "'))", 1000);
Here's the example in entirety:
<html>
<head>
<title>test</title>
<script type='text/JavaScript'>
function GetTime(TimeAnchor) {
today = new Date();
TimeAnchor.innerHTML = today.toLocaleString();
delete today;
}
function UpdateTime(TimeAnchor) {
GetTime(TimeAnchor);
setInterval("GetTime(document.getElementById('" + TimeAnchor.id + "'))",
1000);
}
</script>
</head>
<body>
<span id='DateTime'></span>
<script type='text/JavaScript'>
UpdateTime(document.getElementById("DateTime"));
</script>
</body>
</html>
setInterval("GetTime(document.getElementById('Time Anchor.id + ");", 1000);
[color=blue]
>On Mon, 14 Jun 2004 16:45:07 +0000, ChrisRath wrote:
>[color=green]
>> Internet Explorer plays a bit more loose with the DOM. You can fix the
>> problem on the invocation by:
>>
>> UpdateTime(document.getElementById("DateTime"));[/color]
>
>Changing the code to:
>
><SCRIPT TYPE='text/JavaScript'>
> function GetTime(TimeAnchor) {
> today = new Date();
> TimeAnchor.innerHTML = today.toLocaleString();
> delete today;
> }
> function UpdateTime(TimeAnchor) {
> GetTime(TimeAnchor);
> setInterval("GetTime(" + TimeAnchor.id + ");", 1000);
> }
></SCRIPT>
>
> Clock should be here!
>
><SCRIPT TYPE='text/JavaScript'>
> UpdateTime(document.getElementById("DateTime"));
></SCRIPT>
>
>Updates the anchor with the time initially but the setInterval still
>doesn't work in Mozilla.
>
>Any ideas?[/color] |