View Full Version : recieving focus

08-20-2005, 01:51 PM
i had thought that you could say if(function) function(); or if(element.method) element.method(); to avoid errors, but apparently not - specifically: ive got an array of form elements, on enter pass focus to the next element in the array. if that element can't recieve focus, go the next one in the array. if we've reached the end of the array, start again at the index of the event element and start going down. if it reaches 0 and still nothing, just return false i guess.

initially tried if(target.focus) target.focus(); but that didnt work, so tried checking all the conditions i could think of (disabled, readonly, display, visibility) but that fails if the parent or the parentparent etc. are disabled, hidden, whatnot.

any suggestions?

08-21-2005, 12:33 AM
You could check for those properties of the parent. If a parent element has an intrinsically inheritable trait that prevents a child element from receiving focus, that condition may be able to be detected. Try:


alert(typeof element.focus)as well as:


alert(typeof element.focus())to see if anything to work with reveals itself. I'd really need to see a more concrete example to give much more advice.