Struppi: [Safari]Javascript: HTML-Objekt durch "name"-Attribut ansprechen

Beitrag lesen

Aus DOM-Sicht geht .getElementsByTagName("td").beitrag2 aus demselben Grund wie document.forms.bla bzw. document.forms.bla.elements.bla mit name-Attributen funktioniert, weil forms und elements auch HTMLCollections sind.

OK, die Erklärung leuchtet ein, aber ist alles andere als logisch, weil nämlich umgekehrt:

var x = document.getElementById("Chat").getElementsByTagName("td").beitrag1;  
alert(x.name);

Der Name gar nicht existiert und wenn ich das hier richtig verstehe:

namedItem

This method retrieves a Node using a name. With [HTML 4.01] documents, it first searches for a Node with a matching id attribute. If it doesn't find one, it then searches for a Node with a matching name attribute, but only on those elements that are allowed a name attribute. With [XHTML 1.0] documents, this method only searches for Nodes with a matching id attribute. ...

dann dürfte es auch nicht funktionieren.

Struppi.