Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error message

Status
Not open for further replies.

jdhanley

Programmer
Oct 27, 2000
11
CA
I have a number of layers at the end of my code, each inside a <DIV></DIV> and right before my</BODY>.

I have a function to hide all the layers when my page loads, and another function that takes an ID as an argument and shows that particular layer.

When I look at it all in Explorer, it works fine. When I look at in
Netscape, my JavaScript console says &quot;document.layerwhoare has no
properties&quot; (where &quot;layerwhoare&quot; is the name of my layer). It shows all my layers at the bottom of my page, one after the other (not in position).

I threw this page on my web site for anyone to have a gander at:
Here's are the relevant snipets of my code:

function hideLayers(){
if (document.all){
document.all(&quot;layerwhoare&quot;).style.visibility = &quot;hidden&quot;;
document.all(&quot;layerwhatdo&quot;).style.visibility = &quot;hidden&quot;;
document.all(&quot;layerwhyare&quot;).style.visibility = &quot;hidden&quot;;
document.all(&quot;layerwhatabout&quot;).style.visibility = &quot;hidden&quot;;
}
else{
document.layerwhoare.visibility = &quot;hide&quot;;
document.layerwhatdo.visibility = &quot;hide&quot;;
document.layerwhyare.visibility = &quot;hide&quot;;
document.layerwhatabout.visibility = &quot;hide&quot;;
}
}

function openLayer(layer_name){
if (document.all){
document.all[layer_name].style.visibility = &quot;visible&quot;;
}
else{
document[layer_name].visibility = &quot;show&quot;;
}
}

<style type=&quot;text/css&quot;>
.test{
position: absolute;
visibility: hidden;
top: 112px;
left: 120px;
}
.main{
position: absolute;
visibility: hidden;
top: 300px;
left: 140px;
}
</STYLE>


<A HREF=&quot;#&quot; onClick=&quot;openLayer('layerwhoare')&quot;>
<IMG SRC=&quot;images/whoare_button_over.gif&quot; VSPACE=0 HSPACE=0 BORDER=0>
</A>


<DIV ID=&quot;layerwhoare&quot; CLASS=&quot;main&quot;>
<FONT FACE=&quot;Arial&quot; SIZE=2>
<FONT SIZE=4>
<B>Who are the People?</B>
</FONT><BR>
We are mostly younger adults 20-40 years old and their children. We are
people who long to love like <A HREF=&quot;whoisJesus.html&quot;>Jesus</A> loved,
and do what <A HREF=&quot;whoisJesus.html&quot;>Jesus</A> did. We are a people of
prayer, who put speaking to the <B>Father</B> above other activities
recognizing <B>He</B> can do so much more than any of us in our own
power.<BR>
<BR>
<CENTER>
<A HREF=&quot;believe.html&quot;>What do we believe?</A> |
<A HREF=&quot;leaders.html&quot;>Our Leaders</A><BR>
<A HREF=&quot;people.html&quot;>The People of Northside Community Church</A> |
<A HREF=&quot;where.html&quot;>Where do we come from?</A>
</CENTER>
</FONT>

</DIV>



Any suggestions as to why it doesn't work in Netscape? Thanks muchly!
:)

John Hanley
john@jhanley.cjb.net
 
I tried that, and now I get &quot;document.layers.layerwhoare has no properties&quot;

The funny thing is, I've done the exact same thing before except calling document.layername.visibility = &quot;hide&quot;; from a mouseover() event in my <A HREF=&quot;#&quot;>HTML code and it worked fine. Now I try the exact same thing from a function in my JavaScript code segment, and it doesn't like it.

Any other suggestions? Thanks a bunch! :)

John Hanley
 
Actually, I checked my code, and the above isn't true. i had done it previously by calling a function, that's why I can't figure out why it won't work this time.

my previous function looks like this:

function hide(){

if (document.all){
document.all(&quot;layer1&quot;).style.visibility = &quot;hidden&quot;;
}
else{
document.layer1.visibility = &quot;hide&quot;;
}
}

and it works just fine.

The one that won't work looks like this:

function hideLayers(){
if (document.all){
document.all(&quot;layerwhoare&quot;).style.visibility = &quot;hidden&quot;;
document.all(&quot;layerwhatdo&quot;).style.visibility = &quot;hidden&quot;;
document.all(&quot;layerwhyare&quot;).style.visibility = &quot;hidden&quot;;
document.all(&quot;layerwhatabout&quot;).style.visibility = &quot;hidden&quot;;
}
else{
document.layerwhoare.visibility = &quot;hide&quot;;
document.layerwhatdo.visibility = &quot;hide&quot;;
document.layerwhyare.visibility = &quot;hide&quot;;
document.layerwhatabout.visibility = &quot;hide&quot;;
}
}
they look very similar, except the first one works, the second one doesn't. I can't figure it out.

See for yourself at:
Thanks again! :)

John Hanley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top