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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visibility in NS 4 again.

Status
Not open for further replies.

gottaski

Programmer
Joined
Jan 4, 2001
Messages
17
Location
US
Can some kind soul out there please tell me why the javascript code below does not work. I have it working in IE and NS 6 (so i took out the code to keep the post shorter).

I'm really losing my mind here. Thanks.

<script language=&quot;javascript&quot;>
function hideFields(){
if(document.layers){
document.layers[&quot;layer1&quot;].visibility = &quot;hide&quot;;
document.layers[&quot;layer2&quot;].visibility = &quot;hide&quot;;
}

</script>
<html>
<head>
<meta NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<LINK REL=stylesheet HREF=&quot;..\sitemap.css&quot; TYPE=&quot;text/css&quot;>
</head>
<body onLoad=&quot;hideFields()&quot;>
<form name=&quot;form1&quot; action=&quot;advancedsearch.asp?action=find&quot; method=&quot;post&quot;>
<font class=&quot;whitebold&quot;>The two boxes below should be hidden!!!</font>
<br><br>
<div ID=&quot;layer1&quot; name=&quot;layer1&quot; style=&quot;position:absolute; left:5; top:105; font-family:verdana, geneva, arial,helvetica,sans-serif; font-size: 11px; Color: white; z-index=1&quot;>Enter search text1:
<input type=&quot;text&quot; name=&quot;sText&quot; size=&quot;28&quot;><br><br></div>
<div ID=&quot;layer2&quot; name=&quot;layer2&quot; style=&quot;position:absolute; left:5; top:105; font-family:verdana, geneva, arial,helvetica,sans-serif; font-size: 11px; Color: white; z-index=2&quot;>Enter search text2:
<input type=&quot;text&quot; name=&quot;sText2&quot; size=&quot;28&quot;><br><br></div>
<input type=&quot;submit&quot; name=&quot;submit&quot;>
</form>
</body>
</html>
 
'visibility' is a property of the style object:

should be:

function hideFields(){
if(document.layers){
document.layers[&quot;layer1&quot;].style.visibility = &quot;hide&quot;;
document.layers[&quot;layer2&quot;].style.visibility = &quot;hide&quot;;
}


...or so I think...don't have NS4 here to test it. The only other peculiarity I remember about NS4 layers is that they have their own document object:

document.layers[0].document.forms[0].elementName; etc...

======================================

if (!succeed) try();
-jeff
 
You are wrong jemminger, [tt]style[/tt] object does not exist in Navigator 4.x

I dont really know what's the problem (the syntax seem to be right), look for JS errors: type &quot;javascript:&quot; in the address field after you load the page.
By the way, I recently noticed that you can use [tt]visible[/tt] and [tt]hidden[/tt] in Navigator 4.x like in all modern browsers instead of [tt]show/hide[/tt].

good luck
 
The javascript error that is generated:

document.layers.layer1 has no properties.

not very helpful to me...anyone else?

thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top