Imar,
This has been a LOOONG thread, and before this even came up we had a
solution that was working.
How the document.getElementsByName came into picture was just optimizing
code (since it might be
different elements than TDs...)
And yes, absolutely, it regards it as an expando. And it will most
likely work without the NAME attribute.
I guess the thing is that it is wrong, it shouldn't return an array
based on the ID when the method is
asking for elements with the same name.
The interesting part, though, is that it works in Netscape 6+ with the
NAME attribute, where it
isn't regarded as an expando.
Just confusing, but when it comes down to it, everything will work just
fine with our problem without that method! :-D
Happy scripting!
/Robert
-----Ursprungligt meddelande-----
Fr=E5n: Imar Spaanjaars [mailto:Imar@S...]
Skickat: den 7 oktober 2002 21:09
Till: JavaScript HowTo
=C4mne: [javascript_howto] Re: SV: RE: REVISITED TD HIGHLIGHTING
Hi Robert and Claudio,
I think the behavior in IE6 is caused by the fact that name is not a
valid
HTML 4 attribute for the <td> element. id is allowed, but name just
isn't.
The fact that IE6 allows a name is implemented by a concept called
expando.
AFAIK, this allows you to add your own attributes on the fly without
causing errors.
So the fact that getElementsByName returns items when they have the same
id
and name is coincidence as this method returns them based on their id.
Leaving out the name attribute would cause the same behavior, if I am
not
mistaken.
I haven't followed this thread completely, but can't you use
getElementsByTagName? This would return all <td> instances. Depending on
your needs, you could still add an id attribute to each <td>, or ask
it's
parent (the <tr>) for certain attributes like id or classname or
whatever.
Imar
At 08:47 PM 10/7/2002 +0200, you wrote:
>I have no idea, Claudio.
>
>But you can use document.getElementsByName for IE to get a collection
>of all the different elements, if you set the same ID on all of them
>(however, this is'nt recommended, because of the problem I described
>below with
>document.getElementById, it's not the way ID is supposed to be used).
>
>
>/Robert
>
>
>
>-----Ursprungligt meddelande-----
>Fr=E5n: Pallone, Claudio [KMR-SPC] [mailto:Claudio.Pallone@k...]
>Skickat: den 7 oktober 2002 11:45
>Till: JavaScript HowTo
>=C4mne: [javascript_howto] RE: REVISITED TD HIGHLIGHTING
>
>
>Hi Robert and thanks for your comments.
>
>You are right. The code works with Netscape 6.02 but not with IE6. So
>if I use the same id attribute for TDs I will only get a reference to
>the first one?? Why did Microsoft did that?? It is much simpler to use
>the getElementsByName!!!
>
>Cheers,
>
>Claudio
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20