[Jslib] forcing focus to next element...whatever it is.

Pete Collins pete at mozdev.org
Thu Sep 18 17:38:52 EDT 2003


Stephen Knight wrote:
> Pete Collins wrote:
> 
>> Stephen Knight wrote:
>>
>>> is there a relatively painless way to get the window to change the 
>>> focus to the _next_ element without requiring knowledge of the name 
>>> of the next element?
>>>
>>> ie; as if the user had hit the tab key (the user doesn't know the 
>>> name of the next element).
>>>
>>> (this way, if I rearrange my window, I don't have to worry about 
>>> whether my code will focus in the correct order).
>>>
>>> thank you for your time.
>>
>>
>>
>>
>> Yea, this is something that keeps coming up. Take a look at this code:
>>
>>   http://www.mozdev.org/lxr/http/source/recall/package/recall.js#L55
>>
>> I need to add a general purpose routine to jslib library 
>> "commonWindow" would be a good place. A func that returns an array of 
>> all the open windows.
> 
> 
> If I'm reading the code correctly, it appears to be going thru the 
> browser windows and then starts looking in each window for elements 
> where id == 'content'.
> 
> forgive me for being slow, but how would I find an (or the next) 
> arbitrary element in a window that was willing to accept ".focus()"...by 
> looking for a property by that name?

The code is to show using nsIWindowMediator to create an enumeration of 
open windows expressed as part of the DOM.

I think I misunderstood your original question.

Is "el.nextSibling" what you are loking for?

var el = document.getElementById("targetEl");
var nextEl = el.nextSibling;



-- 
Pete Collins
www.mozdev.org
www.mozdevgroup.com




More information about the Jslib mailing list