Click to See Complete Forum and Search --> : hide layer not working on netscape


vargon
03-24-2003, 02:38 PM
I am using this script to show hide layers;

<head>
<script type="text/javascript">

function show(id)
{
eval("document.all." + id + ".style.visibility = 'visible';");
return;
}

function hide(id)
{
eval("document.all." + id + ".style.visibility = 'hidden';");
return;
}

</script>
</head>
<body>
<a href = "#" onclick = "hide('layer1');"
</body>

This works fine on IE and Opera but it isn't working on Mozilla or Netscape7. Any ideas why? Or what I should use?

khalidali63
03-24-2003, 02:55 PM
try this link

http://68.145.35.86/skills/javascripts/NSShowHide.html

Cheers

Khalid

vargon
03-24-2003, 04:11 PM
nothing on that link.

got any others?

khalidali63
03-24-2003, 04:16 PM
LoL...my fault the link I posted earlier only works with NS4+ but <6 browsers

try this..typically there is not much diff between IE6+ or NS6+ browsers functionality for hiding or showing a layer

http://68.145.35.86/skills/javascripts/ShowHideFormElement.html

Cheers

Khalid

gil davis
03-25-2003, 06:01 AM
Mozilla and NS do not support document.all. That is an IE only thing. You should use the W3C DOM method document.getElementById(). The following will work in the majority of browsers:function show(id) {
if (document.getElementById)
{document.getElementById(id).style.visibility = "visible";}
else
{if (document.layers)
{document.layers[id].visibility = "show";}
else
{document.all[id].style.visibility = "visible";}
}
}