Andy Chambers wrote:
On both Opera and Firefox, getElementsByTa gName doesn't find anything
apart from <optionelemen ts inside a select element. Why is this?
You are trying to use extended XHTML, and your markup is not Valid.[1] The
"Extensible " in XHTML does _not_ mean "anything goes"; if you want to extend
XHTML, you need to declare a namespace for all non-XHTML elements and
attributes and a DTD or a Schema that declares these elements and
attributes. And of course you must comply with the XHTML DTD (that you
missed to declare here), which says in your case (assuming XHTML 1.0
Transitional or Strict):
| <!ELEMENT select (optgroup|optio n)+ <!-- option selector -->
Meaning that an XHTML `select' element must contain at least one of
`optgroup' or `option' elements.
[...]
Is this because only <option>s <select>s?
Parse error.
<html xmlns="http://www.w3.org/1999/xhtml">
This declares the XHTML namespace as the default namespace.
[...]
var elems = document.getEle mentsByTagName( "xref");
[...]
<body>
[...]
<select>
<xref ref="1"/>
</select>
[...]
</body>
</html>
Therefore, you need to use namespace-based accessor methods in an XHTML
document. Suppose your `xref' element was declared in
<http://achambers.me.uk/dtds/ac.dtdlike this:
...
<!ELEMENT select (optgroup|optio n|xref)+>
...
<!ELEMENT xref EMPTY>
<!ATTLIST xref
ref CDATA #REQUIRED
>
...
And used like this:
<DOCTYPE html PUBLIC "-//AChambers//DTD XHTML 1.0 plus ACMarkup//EN"
"http://achambers.me.uk/dtds/xhtml1-acmarkup.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
xmlns:ac="http://achambers.me.uk/acmarkup"
xml:lang="en">
...
<body>
...
<ac:xref ref="1"/>
...
</body>
</html>
You would access it like this:
var elem = document.getEle mentsByTagNameN S(
"http://achambers.me.uk/acmarkup", "xref")[0];
PointedEars
___________
[1] <http://validator.w3.or g/>
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8************ *******@news.de mon.co.uk>