[thelist] Re: Accessing layers in Javascript
Mark Howells
mark at mountain.ch
Wed Jan 30 11:38:01 CST 2002
> The code below will work in Netscape 6.x and Opera, if you want to get
> all
> the DIVs and then do something only to a specific class (assuming your
> layers are in DIV tags). This method is good if you use CLASS to group
> layers, and ID to identify a specific layer:
>
> --
> var Layer = document.getElementsByTagName("DIV");
> for (var i = 0; i < Layer.length; i++)
> if (Layer[i].getAttribute('class') == "your_class_name")
> // do something
> --
Looks good, but I'm trying to loop through all layers and if the id
contains "menu" then I want to incrementally increase a counter
variable. This needs to work in browsers which support document.layers,
document.all and document.getElementById.
I've tried changing the code to
if (Layer[i].getAttribute('id') == "menu1")
(as a first step) but this doesn't work in NN6 or IE5/Mac. Any futher
suggestions?
Regards
Mark Howells
<http://www.mark.ac/evl>
More information about the thelist
mailing list