Re: Nested Accordion Menu
- From: Thomas 'PointedEars' Lahn <PointedEars@xxxxxx>
- Date: Thu, 08 Jan 2009 21:02:28 +0100
Jeremy J Starcher wrote:
On Thu, 08 Jan 2009 07:29:28 -0800, ibizara wrote:
I have got the menu nested now although I am sure there is more than
likely a better way to achieve the same goal.
I find it very hard to believe this code works reliably.
Though slightly off-topic, I strongly recommend AGAINST nested menus for
accessibility reasons. In fact, I am slowly removing them from the web
site I am responsible for.
---CODE---
<script type="text/javascript" charset="utf-8"> function toggleMe(a,b){
var e = document.getElementById(a);
for (var i = 0, divs = document.getElementById
("container_"+b).getElementsByTagName("container_"+b); i < divs.length;
++i){
You cannot simply make up your own tags.
To be fair, the OP is not making up anything *here*. However, it depends
very much on the DOM (thus, on the UA), on the document type and layout mode
which element objects will be found with the getElementsByTagName() method.
[...]
</script>
<style type="text/css">
.subs{
margin-left: 5px;
}
</style>
Let's hope that all this is just invalid HTML and not cluelessly written
XHTML, for otherwise the script element would not be well-formed because of
the unescaped `<', and </head> and <body> would be missing here, too.
In any case, I would recommend not to omit those two tags. In particular,
the `script' element is allowed both within the `head' element and the
`body' element; it may not be obvious where the `head' element ends and the
`body' element begins, even though it could be deduced by the parser from
the `style' element, which only belongs within the `head' element.
<div id="container_1">
<a href="javascript:;" onclick="return toggleMe('sub_1',1)">
Invalid href. Best to have the href point to a valid target. If you
*must*, use href="#" as the target.
Certainly not invalid, but very unwise. Syntactically, `javascript:;' is a
valid absolute URI as per RFC 3986; however, there will be a hyperlink that
is not really a hyperlink (doesn't navigate), and it will not work without
support for the `javascript:' URI scheme (and may generate errors when
clicked), but it will be displayed anyway. See also the FAQ.
Title1</
a><br />
<container_1 id="sub_1" style="display:none" class="subs">
Wrong, wrong, wrong, wrong, wrong.
Simply overbrimming in wrongability.
Well, to be fair, it depends. Since the OP uses XHTML tag style and we have
not seen the DOCTYPE declaration yet, there is the remote possibility that
the DTD or the internal subset declares this element. The only thing left
to be found would be a user agent that renders it properly. But then, it
might be server-side code which is transformed before being served, or it
may be transformed client-side with XSLT. (I'm only talking about
possibilities here; the rest of the code rather shows signs of cluelessness
at work.)
PointedEars
.
- Follow-Ups:
- Re: Nested Accordion Menu
- From: Jeremy J Starcher
- Re: Nested Accordion Menu
- References:
- Nested Accordion Menu
- From: ibizara
- Re: Nested Accordion Menu
- From: ibizara
- Re: Nested Accordion Menu
- From: Jeremy J Starcher
- Nested Accordion Menu
- Prev by Date: Re: innerHTML doesn't work on IE?
- Next by Date: Re: Nested Accordion Menu
- Previous by thread: Re: Nested Accordion Menu
- Next by thread: Re: Nested Accordion Menu
- Index(es):
Relevant Pages
|