> ARGH -- that JavaScript is huge!
>
> It is neither of those -- The JavaScript I ended up using was one very
> short function.
Ok, just quickly, and speaking as a member of the WaSP DomScripting Task Force:
The size of a JavaScript is NOT a measure of how clever, good or bad
it is. What it _does_, how clean it does it and how nicely it plays
with other scripts and different environments is what is important.
All of these matters are very complex and do mean that there are hacks
and workarounds at the moment, all of them making the scripts larger
than needed, much like a lot of CSS hacks make a CSS file less
readable. They are necessary however, as short and quick scripts
simply are a lot less failsafe or expect a special user agent or
elements to be available.
You can make a nested navigation clickable and collapsing by this:
window.onload=function()
{
n=document.getElementById('nav');
uls=n.getElementsByTagName('ul');
for(i=0;i<uls.length;i++)
{
uls[i].style.display='none';
uls[i].parentNode.getElementsByTagName('a')[0].onclick=function()
{
u=this.parentNode.getElementsByTagName('ul')[0];
u.style.display=u.style.display=='none'?'block':'none';
return false;
}
}
}
However, it will make your navigation unusable for screen readers, not
allow for other scripts to be used on the page, and might break when
your navigation HTML has whitespace in it.
A lot of developers are creating a newer breed of scripts that CSS
developers can use without knowing anything about JavaScript to apply
them. These scripts apply the functionality CSS is not capable to
deliver in a cross browser fashion and keep the complete look and feel
in CSS classes that get applied and removed dynamically. This makes
the scripts bigger, but also a lot more versatile.
Think of these scripts as a CSS helper, not as something you have to
grasp or should change without knowing what you do.
We stopped mixing presentation and HTML, now we start taking the
presentation of the DHTML days out of the scripts and put them into
the CSS, where they should be.
This will help web development in the future and cut down on
maintenance time and frustrating hours before the machine for all of
us.
Don't trust scripts that ask you to change them to make them look
different, or promise the moon on a stick - there is just no silver
bullet in web design, our environment is far too diverse for that.
Our safest bet is to keep the different layers separated and work
together towards good and clever solutions. This also involves
restraint and understanding of each others' problems.
regards,
Chris
--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/