Re: Nested Accordion Menu



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.

Title
1</
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
.



Relevant Pages

  • Re: Nested Accordion Menu
    ... I strongly recommend AGAINST nested menus ... Let's hope that all this is just invalid HTML and not cluelessly written ... I would recommend not to omit those two tags. ... it may not be obvious where the `head' ...
    (comp.lang.javascript)
  • Re: WebBot Substitution
    ... The Page Title is stored in the page itself, in the <head> section between ... > of the page on the General tab are being published. ... >>tags of a page, not the head section of a page. ... >>FrontPage Resources, WebCircle, MS KB Quick Links, etc. ...
    (microsoft.public.frontpage.extensions.windowsnt)
  • Re: Reading HEAD section META tag (name / content).
    ... all html between two server controls is stuffed into one generic. ... <head runat=server> ... you will a generic for the tag which will have a control collection ... to include the ability to read the inheriting class/page meta tags. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Ruby Version History
    ... construct them from the tags/ directory of the SVN repo. ... to checkout tags you'll get gigabytes of mostly redundant ... svn: Can't write to stream: Broken pipe ...
    (comp.lang.ruby)
  • Re: wrapping attributes?
    ... that into the head of this document. ... I just discovered that while all of the hyperlinks in the ... also emphasized, so while the style rule in ... looks like I will have to manually edit most of the tags one at a time ...
    (comp.infosystems.www.authoring.html)