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

Invalid argument for visibility property?

Status
Not open for further replies.

jimny

Technical User
Oct 18, 2002
52
US
I wrote this snippet for an expandable directory listing and it returns a JAVASCRIPT ERROR:

Line 64:
Char 8
Error: Coould not get the Visibility property. Wrong argument


Here is the code:


<HTML>
<HEAD>
<TITLE>My Drop Down</TITLE>
<SCRIPT LANGUAGE=javaScript>
<!--
//First DropDown Menu
var ary1 = new Array();
//don't know why these appear so funny in this post
//there is only 1 semicolon at end of each line
ary1[0] = &quot;<A HREF=\&quot; ary1[1] = &quot;<A HREF=\&quot; ary1[2] = &quot;<A HREF=\&quot; ary1[3] = &quot;<A HREF=\&quot;
//Determine Browser
var IE = document.all?true:false;
var NN = document.layers?true:false;
var WW3 = document.getElementById&&!document.all?true:false;
var OP = navigator.userAgent.indexOf(&quot;Opera&quot;)?true:false;

var dvFavs;
var dvlst1;

function OnLoad()
{
//Format &quot;visibility&quot;
if (IE||OP)
{
hide= &quot;hide&quot;;
show= &quot;show&quot;;
}
if (NN)
{
hide= &quot;hidden&quot;;
show= &quot;visible&quot;;
}
if (WW3)
{
hide= &quot;hidden&quot;;
show= &quot;visible&quot;;
}
//Format DIV's
dvFavs = Lens(&quot;Favs&quot;);
dvlst1 = Lens(&quot;list1&quot;);
}

function Lens(obj)
{
if (NN)
dv = document.layers[obj]
if (WW3)
dv = document.getElementById(obj)
else
dv = document.all[obj]
return dv;
}

function ExpColl(dv)
{
if (dv.style.visibility == hide)
{
dv.style.visibility = show;
}
else
{
dv.style.visibility = hide;
}
}
//-->
</SCRIPT>
</HEAD>

<BODY onload=&quot;OnLoad();&quot;>
<FORM>
<TABLE border=0>
<TR>
<td>
<DIV class=Parent ID=Favs onClick=&quot;ExpColl(dvlst1);&quot;>My Favorites
<DIV ID=list1 style=&quot;position:absolute;left:0;top:0;width:120;visibility:hidden;&quot;>
<script language=&quot;JavaScript1.2&quot;>
<!--
for (i=0;i<ary1.length;i++)
document.write(ary1);
//-->
</script>
</DIV>
</DIV>
</td>
<TR>
<TR>
<td>
</td>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>


Can anyone spot an obvious error?
Thanks...
 
chmohan,
Thanks for the reply, but it is a little cryptic for me. I am using IE 6.0 and I hope that style.visibility is &quot;hide&quot;, but what is causing the page to throw the error?
 
<DIV ID=list1 style=&quot;position:absolute;left:0;top:0;width:120;visibility:hidden;&quot;>

shouldnt the above be

<DIV ID=list1 style=&quot;position:absolute;left:0;top:0;width:120;visibility:hide;&quot;>

 
Thnaks for the quick response but...
If I change it to &quot;visibility:hide&quot; in the style attributes of the DIV tag, that DIV is visible and I still generate the same error. Is there an issue with the logic in the ExpColl function since I return the error &quot;onclick&quot;, or is the logic of the whole idea flawed?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top