How to detect invisibility on element contained inside invisible parent?

Giganews Newsgroups
Subject: How to detect invisibility on element contained inside invisible parent?
Posted by:  jera‚Ķ@hotmail.com (Jeje)
Date: 3 Oct 2003

Hi,

I'm trying to detect if an input field is visible or not in order to
put the focus inside it (or else it cause th error : "Can't move the
focus ot the control because it is invisible, not enabled, or of a
type that does not accept the focus").

I'm using css to set the visibility. But the visibility style of the
input field itself is not set, the parent that contains the input is
the one set invisible. Here's a simple example that shows what I'm
talking about:

<table style="visibility:hidden">
  <tr>
    <td><input type="text" name="MyInput"/></td>
  </tr>
</table>

So in this example, if you try to put the focus inside the input it
cause the error because the parent table renders it invisible.
(Myinput.style.visibility doesn't work either)

I know i could do a loop to look if any parents have the visibility
set to "hidden", but I'm searching for something more "easy",
something like the function "isDisabled" or "isContentEditable"...
(something like "isVisible" would be perfect... if it existed! )

Thanks for your time! :)

jeje

Replies