473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Jul 20 '05 #1
1 11286
Ivo
"Jeje" <je****@hotmail.com> wrote in message
news:f3**************************@posting.google.c om...
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").


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
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Markus Ernst | last post by:
Hello Reading the follwing document: http://www.w3.org/TR/WD-positioning-970131#In-flow it seems very clear that position:relative should be relative to the parent element. So in the following...
1
by: liberty | last post by:
Hi, I have looked everywhere to try and solve my problem-- looked at W3C DOM Compatibility charts, read articles, tried debuggers, and still my script is not working. The problem I have is this. ...
5
by: Patient Guy | last post by:
In my reading of the Strict and Transitional DTD for HTML 4.0, the table row (TR) elements are contained within table section elements: THEAD, TFOOT, and TBODY. The table section elements are...
4
by: Hollywood | last post by:
I'm using XML serialization to produce the following XML document: <TestDoc xmlns:srd="some-url"> <Additional> <Security> <srd:Login>login_id</srd:Login> <srd:Password>password</srd:Password>...
18
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. ...
4
by: Andreas Borutta | last post by:
Hi, what is the task with which I could not cope? There is a link with an inline-element (strong e.g.) inside. It has a higher font-size than the content of its parent. For the hover effect...
4
by: TS | last post by:
I am losing my colgroup html element of a table that i toggle back and forth of being visible=true/false. is there any workaround since the rendered html doesn't contain it even though it has not...
7
by: dweeti | last post by:
Hi, I am trying to display the child element in the DOM, while hiding the parent using JS and CSS, however I cannot find a way to do this. So for example: <body> <div id="Parent"> <div...
5
by: SuneR | last post by:
Hi, I am having problems figuring out how to make Firefox behave, and output the HTML I want it to output. The thing I want done is actually quite simple. I have a <labeltag, and inside it, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.