Thanks for the reply.
I used the following code and I thought it was working (at least on
netscape and firefox) unitl I tested it with IE, wehere it chokes:
<style>
The type attribute is required:
<style type="text/css">
But you don't really need to use classnames for this exercise.
[...]
<script language="javascript>
Richard was suggesting that you drop the depreciated language attribute
and include the required type attribute:
if (document.getElementById)
{
function getElemById(id)
{
return document.getElementById(id);
}
Not much point in attempting replace a function with itself - if
getElementById is supported (which is likely more than 95% of browsers
in use on the web), just leave well enough alone. If all you want to
do is provide an alternative for browsers that don't support
finding an element using getElementById, then test for them explicitly.
And though Richard pointed out that you can't have conditional function
declarations, you can conditionally declare a function:
if ( !document.getElementById ) {
if ( document.all ) {
document.getElementById = function(id) {
return document.all[id];
}
} else if ( document.layers ) {
document.getElementById = function(id) {
return document.layers(id);
}
} else {
document.getElementById = function(id) {
return null;
}
}
}
The above does not support all the features of getElementById, but
should be sufficient for simple calls.
[...]
function hide(ele)
{
getElemById(ele).className = "noshow";
}
function show(ele)
{
getElemById(ele).className = "menu";
}
Hide and show can be done in one function that just toggles between
'none' and '', which should be suitable for most situations. It's
probably useful to test that the style object is supported too:
function showHide( ele ) {
if ( ele.style )
ele.style.display = (ele.style.display == '')? 'none' : '';
}
}
In case style or javascript aren't supported, any elements that are
essential to the use of the page should be visible by default. If you
want them hidden on page load, then hide them with script using onload
or strategically placed script elements (e.g. just after each element
or group of elements that you want to hide).
[...]
Ah, there's the answer...