Entry
Why is the text property of alink not available sometimes to a certain link ?
Jun 12th, 2002 06:21
David Blackledge, sharon,
First, let's note that the "text" property is only a property of links
in Netscape 4. It's not available in IE or Netscape 6 (I assume...
because it's not part of the W3C DOM).
In Netscape 4, they got a little weird when it came to dealing with
links versus anchors. Since both use the "A" tag, they got a bit
confused. If you specify an HREF value, the item is a link. If you
specify a NAME value, the item is an anchor. If you specify BOTH, it
shows up in BOTH arrays, except only PARTS are in both arrays.
Specifically, an A tag with both an HREF and a NAME has a Link object in
the links array where the text, x, and y properties are all NULL. It
also has an Anchor object in the anchors array which has "stolen" the
text, x, and y properties and still has its usual "name" property.
(Link objects in the links array do not ever have a name property).
So, if you specify a "name" property, your text property will be null on
the link.
Even more maddening is there is NO way to match up the Link object to
the Anchor object to get all of the data together. There is no shared
information, and the links and anchors arrays are independent. The best
you could hope for is if you make EVERY link into both a link AND an
anchor by including a NAME, then the array indices would match up.
David.
http://David.Blackledge.com