Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 11:56 AM
Jeje
Guest
 
Posts: n/a
Default How to detect invisibility on element contained inside invisible parent?

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
  #2  
Old July 20th, 2005, 11:56 AM
Ivo
Guest
 
Posts: n/a
Default Re: How to detect focusability?

"Jeje" <jerars@hotmail.com> wrote in message
news:f3a207c2.0310031141.44bd52f7@posting.google.c om...[color=blue]
> 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").[/color]

try{
document.myform.myinput.focus();
}
catch(e){
alert('Could not focus on myinput.');
}

Better than checking visibility, you want to check focusability. The
try-catch should stop any errors.
Ivo


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles