CSS: visibility property

  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Ok... here's the problem:

In an included CSS file (other elements are working...)
Code: [ Select ]
#dummy{ visibility:visible; position:absolute; z-index:0; }


In the document that CSS file is included on, I have, at the top, just under the body tag:
Code: [ Select ]
<span NAME="dummy" ID="dummy"><img SRC="/graphics/common/spacer1x1.gif" HEIGHT="1" WIDTH="1"></span>

(spacer1x1.gif is a transparent gif used for, duh, spacing stuff)


Then, at the very bottom of the same document, I have:
Code: [ Select ]
<p><b>visibility</b>:
<script LANGUAGE="JavaScript" TYPE="text/javascript">
document.write(document.getElementById("dummy").style.visibility);
</script></p>
  1. <p><b>visibility</b>:
  2. <script LANGUAGE="JavaScript" TYPE="text/javascript">
  3. document.write(document.getElementById("dummy").style.visibility);
  4. </script></p>



This prints out:
visibility:

That's it... regardless of whether I set the visibility to visible or hidden. Now... if I set the visibilty to hidden, it does, in fact, get hidden. So it is working in that regard. If I explicitly set the visibility object to "hidden" with JavaScript, it will print out AND hide the layer.

I've done this a thousand times, so I must just be overlooking something this time... any idea?

(There is a reason why I'm doing this, but I'll post a seperate topic about that since it's sort of its own topic all by itself...)

.c
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

Have a look at this article which addresses this issue:

http://dhtmlkitchen.com/learn/js/setstyle/index4.jsp

By the way, if you try to use the function examples I think you'll find a bug in the toCamelCase function if you try to pass it a hyphenated value like background-color: it returns BackgroundColor instead of backgroundColor as it should, but it's pretty easy to fix.

With the fix in place it worked fine for visibility. However I did note that when I tried it with both IE and Firefox with a setting of background-color:blue in the style sheet IE returned "blue" and Firefox returned the rgb value, so in some cases you might not get exactly what you expect.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 20 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.