[Javascript] Layer can't be accessed in IE

Andrew Dunn adunn at mail.interworx.com.au
Thu May 17 01:29:15 CDT 2001


Hi I have a problem with layers also,

I have a page that hides/shows layers when a user selects different options
from a radio button. But when I open the page in Netscape 4 the browser
crashes, i think this is due to the fact of the layers because when I
comment them out it works fine. I detect the browser type like so and set
variables according to the browser type:

function checkBrowser()
{
	if(navigator.userAgent.indexOf("MS") != -1)
	{
		isIE = true;
		layer = ".all";
		style = ".style";
	}
	else if(navigator.userAgent.indexOf("Nav") != -1)
	{
		isNav = true;
		layer = ".layers"
		style = "";
	}
	else
	{
		unSupported = true;
	}
}

I show and hide layers with lines like so:

eval("document" + layer + "['SectionT']" + style + ".visibility =
'visible'");

Can anyone see the flaw that would cause netscape to crash? This works fine
in IE.

Thank you.
Andrew

-----Original Message-----
From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]On
Behalf Of Reuben D Budiardja
Sent: Thursday, 17 May 2001 4:13 PM
To: javascript at LaTech.edu; javascript at LaTech.edu
Subject: RE: [Javascript] Layer can't be accessed in IE


Works great.

Thanks a lot.
Reuben D. B.

At 05:06 PM 5/17/2001 +1200, Andrew Gibson wrote:
>Something like this?
>
>    document.all["advance_search"].style.visibility = 'hidden';
>
> > Hi all,
>  > I have a page with layer, and a link to switch between one layer to the
>  > other. The link will run the javascript function that will
>  > change the layer
>  > to hide and visible. This works well with Netscape 4.7, but does
>  > not work
>  > in IE. How does one access the layer object in IE? any help will
>  > be greatly
>  > appreciated. The following is the simplified code.
>  >
>  > Thanks.
>  > Reuben D. Budiardja
>  > -------------------------------
>  >
>  > <SCRIPT>
>  > function toSimpleSearch()
>  >    {
>  >    document.layers["advance_search"].visibility = 'hidden';
>  >    document.layers["simple_search"].visibility = 'visible';
>  >    }
>  > function toAdvanceSearch()
>  >    {
>  >    document.layers["advance_search"].visibility = 'visible';
>  >    document.layers["simple_search"].visibility = 'hidden';
>  >    }
>  > </SCRIPT>
>  >
>  >
>  > <DIV id="simple_search" style="position:absolute; width:480px;
>  > height:1000px; z-index:1; left: 10px; top: 10px; visibility: visible">
>  > <A HREF="javascript:toAdvanceSearch()">Advance Search</A>
>  > <!-- HTML TABLE and FORM -->
>  > </DIV>
>  >
>  > <DIV id="advance_search" style="position:absolute; width:480px;
>  > height:1000px; z-index:1; left: 10px; top: 10px; visibility: hidden">
>  > <A HREF="javascript:toSimpleSearch()">Simple Search</A>
>  > <!-- HTML TABLE and FORM -->
>  > </DIV>
>  >
>  >
>  > _______________________________________________
>  > Javascript mailing list
>  > Javascript at LaTech.edu
>  > http://www.LaTech.edu/mailman/listinfo/javascript
>  >
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>http://www.LaTech.edu/mailman/listinfo/javascript


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
http://www.LaTech.edu/mailman/listinfo/javascript





More information about the Javascript mailing list