I am having trouble getting this script to work in Netscape although it works fine in Internet Explorer. (Seems to be common....hmmmm) I also want the link to hide all the other div's with id's that start with "obj" - I haven't been able to get it to recognize the "obj" in the id to filter them out I tried using a substr but the first div it ran into is one that doesn't exist in my html and had no name or id (????) so I got errors each time. The only way I could get around it was with a counter that skips the first two divs, but I would rather do it the right way.
Anyways, here is the html code that calls it:
<a href="#" onclick="javascript:hideAl
l();show('
objcontent
');">Conte
nt Management Systems</a><br><br>
here is an example of the objects to show/hide:
<div id="objcontent" style="visibility:hidden; Z-INDEX: 1; POSITION: absolute; LEFT: 470px; TOP: 112px; width: 304px; height: 277px;">content here</div>
and here is the javascript:
function hideAll()
{
var array1 = new Array();
var array2 = new Array();
var counter;
counter = 0
array1 = document.getElementsByTagN
ame("div")
;
for(var item in array1)
{
counter = counter + 1;
if (counter > 2) //counter to skip the first two (workaround)
{
if(array1[item].id.substr(
0,3) == "obj") //this line gives an error if the counter isn't there
{
array2[counter] = array1[item];
}
}
}
for(var item in array2)
{
document.getElementById(ar
ray2[item]
.id).style
.visibilit
y="hidden"
;
}
};
function show(pick){
document.getElementById(pi
ck).style.
visibility
="visible"
;
};
Please help me, if you can, to:
1. Filter out div id's by their prefix properly
2. Make the script show and hide the div's in Netscape
Thank You
Start Free Trial