473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help convert code from IE to Mozilla

Hey Folks,

This code works in IE but not in Mozilla. I'd like it to work in both. I'm
sure it has something to do with the way I'm passing the anchor object but
I can't figure it out.
<SCRIPT TYPE='text/JavaScript'>
function GetTime(TimeAnchor) {
today = new Date();
TimeAnchor.innerHTML = today.toLocaleString();
delete today;
}
function UpdateTime(TimeAnchor) {
GetTime(TimeAnchor);
setInterval("GetTime(" + TimeAnchor.name + ")", 1000);
}
</SCRIPT>

<A NAME='DateTime'>
Clock should be here!
</A>

<SCRIPT TYPE='text/JavaScript'>
UpdateTime(DateTime);
</SCRIPT>

--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #1
5 1704
Internet Explorer plays a bit more loose with the DOM. You can fix the problem
on the invocation by:

UpdateTime(document.getElementById("DateTime"));

This code works in IE but not in Mozilla. I'd like it to work in both. I'm
sure it has something to do with the way I'm passing the anchor object but
I can't figure it out.
<SCRIPT TYPE='text/JavaScript'>
function GetTime(TimeAnchor) {
today = new Date();
TimeAnchor.innerHTML = today.toLocaleString();
delete today;
}
function UpdateTime(TimeAnchor) {
GetTime(TimeAnchor);
setInterval("GetTime(" + TimeAnchor.name + ")", 1000);
}
</SCRIPT>
Clock should be here!
<SCRIPT TYPE='text/JavaScript'>
UpdateTime(DateTime);
</SCRIPT>


Jul 23 '05 #2
On Mon, 14 Jun 2004 16:45:07 +0000, ChrisRath wrote:
Internet Explorer plays a bit more loose with the DOM. You can fix the
problem on the invocation by:

UpdateTime(document.getElementById("DateTime"));


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>
<A ID="DateTime">
Clock should be here!
</A>
<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?

--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #3
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);

On Mon, 14 Jun 2004 16:45:07 +0000, ChrisRath wrote:
Internet Explorer plays a bit more loose with the DOM. You can fix the
problem on the invocation by:

UpdateTime(document.getElementById("DateTime"));


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?

Jul 23 '05 #4
On Mon, 14 Jun 2004 18:16:21 +0000, ChrisRath wrote:
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>


That appears to break the setInterval under both browsers... does this run
for you?

--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #5
On Mon, 14 Jun 2004 13:39:01 -0500, Ivan Marsh wrote:
That appears to break the setInterval under both browsers... does this run
for you?


Scratch that! Had a typo... now it works in both.

Thanks.

--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris | last post by:
Hi I have designed my website to fit my standard windows. I use a javascript scroller that nescitates the removal of the browser scroll bars. However if a user has an extra toolbar open in...
8
by: Mike Gifford | last post by:
Hello, I've got a number of html fragments (in a template file) which are bundled together in a cms. I'm sure that there's a way through javascript to convert a piece of code like this: ...
5
by: kj | last post by:
I have elements of the form <TD><A name="marker"></A>foobar</TD> and I want to extract the text "foobar". How can I do this in IE? (I think I know how to do it for NS). Is there a way to...
9
by: YZK | last post by:
Hello. I'm not a Web developer, just a user, and I think I may have somehow messed myself up majorly. I'm not quite sure how. Right now, javascript used by websites I go to either does not work at...
1
by: Paul Gorodyansky | last post by:
Hi, More than a year passed since Netscape/Mozilla implemented what IE had since IE 5: http://www.faqts.com/knowledge_base/view.phtml/aid/1661 Is Opera still behind and does not allow...
2
by: Jon Smirl | last post by:
I only have a passing acquaintance with Python and I need to modify some existing code. This code is going to get called with 10GB of data so it needs to be fairly fast. ...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
8
by: Tim Nash (aka TMN) | last post by:
Hi Can anyone help me match this div below - my regex does not work - if you could tell me why I would appreciate it. var aStr = "<div class='feedflare'>dfgdg dg</div>"; var reg = new...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.