[thelist] Re: Accessing layers in Javascript

Hassan Schroeder hassan at webtuitive.com
Wed Jan 30 12:10:00 CST 2002


Mark Howells wrote:

> 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?

How 'bout

	if ( Layer[i].id.indexOf("menu") > -1 )

(only tested on Moz/Win - no Mac available!)

HTH!
--
H*
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

    -- creating dynamic Web sites and applications since 1994 --



More information about the thelist mailing list