"Mark" <an*******@devdex.com> wrote in message
news:3f*********************@news.frii.net...
<snip>
function openIt(faq) {
showIt = document.all(faq);
Netscape/Mozilla/Gecko browsers do not have a document.all collection so
the above line will produce errors and the rest of the function will not
be executed.
If the parameter - faq - contains a string that represents the unique ID
of an HTML element (as appears to be the case, with the caveat that
"22list" is not a valid ID attribute string according to the HTML 4
specification) then the W3C DOM standard document.getElementById method
could be used, possibly with a fall back to document.all to accommodate
IE 4.
Incidentally, document.all is an object so its named properties should
be accessed using square brackets instead of parenthesise. IE does its
error correcting/tolerance thing with code like this but other browsers
that do implement a document.all collection (there are quite a number
these days) may not be so tolerant.
if (showIt.style.display == "none") {
showIt.style.display = ""
} else {
showIt.style.display = "none"
}
}
..and the onclick code is:
<a href="#" onclick="javascript:openIt('22list');
return false;">click here to toggle</a>
<div id="22list" style="display:none">
<snip>
Initially setting the display property to none means that any visitors
to the page who have JavaScript disabled/unavailable will be presented
with a non-functional/useful link and never be able to view the content
of the DIV (unless they view the page source). Generally, if content is
to be hidden and revealed with scripts it would be better to have it
initially visible and hide it in the onload event so that the content
will be available to the users without JavaScript. Additionally, the
link is meaningless without scripting so it should probably be included
in the document using a script, so that without client-side scripting
the user doesn't ever get the impression that there was any dynamic
mechanism on the page, and certainly not the impression that it is
broken.
Richard.