SOLVED RE: [thelist] Javascript and hidden layers - odd onclick b ehaviour

Joel Canfield joel at spinhead.com
Mon Feb 24 16:58:01 CST 2003


--
[ Picked text/plain from multipart/alternative ]
> what's causing this is the storage of the state in a single
> variable.  one word -- don't.  check the state of the object
> itself before deciding what to do.

Fair enough. Copied code, logic not mine, not enough time to analyze.

Function below is near perfect: two typos - 'documet' in line 2 s/b
'document' and 'visibile' in the last line before the two closing brackets
should be 'visible' - this one gave no error and required that I actually
read the code and use my brain. Tough stuff for a Monday.

Much coolness. Thanks jeff.

> function showhide(layerID)
> {
>   if(documet.getElementById)
>     layerObj = document.getElementById(layerID);
>   else if(document.all)
>     layerObj = document.all[layerID];
>   else
>     layerObj = null;
>   if(layerObj)
>   {
>     visibility = layerObj.style.visibility;
>     layerObj.style.visibility = (!visibility || visibility ==
> 'visibile') ? 'hidden' : 'visible';
>   }
> }



More information about the thelist mailing list