[thelist] Re: Re: Re: Accessing layers in Javascript
Ben Gustafson
Ben_Gustafson at lionbridge.com
Wed Jan 30 13:01:00 CST 2002
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--
[ Picked text/plain from multipart/alternative ]
(Oops! Replying to my own post)
Mark,
if (Layer[i].id.indexOf("menu") != -1)
will work both in IE and in NN6. Thus, the repeated code for the two
browsers can be cleaned up a bit.
--Ben
> > 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?
>
> For lack of A) insight on how to fork the code for the
> browser without repeating, and B) knowledge of how to get the
> layer ID string in Netscape 4.x, I'd try this:
>
> <SCRIPT LANGUAGE="JavaScript1.2"><!--
> var counter = 0;
>
> if (browser == "Gecko") {
> var Layer = document.getElementsByTagName("DIV");
> for (var i = 0; i < Layer.length; i++)
> if (Layer[i].getAttribute('id').indexOf("menu") != -1)
> counter++;
> } else if (browser == "IE") {
> var Layer = document.all.tags("DIV");
> for (var i = 0; i < Layer.length; i++)
> if (Layer[i].id.indexOf("menu") != -1)
> counter++;
> } else if (browser == "NS4") {
> alert("Upgrade your piece of crap browser!");
> }
> //--></SCRIPT>
>
> --Ben
More information about the thelist
mailing list