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

Stephen Knight stknight at ultralifebatteries.com
Thu Sep 18 17:59:48 EDT 2003


Pete Collins wrote:

[ snip ]

> 
> 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.

I'm afraid so.

> 
> Is "el.nextSibling" what you are loking for?
> 
> var el = document.getElementById("targetEl");
> var nextEl = el.nextSibling;

almost.  It definitely allows me to focus on the next element, but I'm trying for a bit more complexity.

as an example:
<box id="group1">
	<menulist id="menu1">...</menulist>
	<menulist id="menu2">...</menulist>
</box>
<box id="group2">
	<menulist id="menu3">...</menulist>
	<menulist id="menu4">...</menulist>
</box>	

by hitting the TAB key, the user can change the focus:  menu1, menu2, menu3, menu4.
Now, it's easy (for me, anyway) to change the focus if I know the name of the next element:
	var newTarget = document.getElementById( "menu3");
	newTarget.focus();

BUT, what I would like is for menu2 to be able to go to the next focusable element without knowing 
the name (or caring).  So, as my user-interface gets readjusted, I can change to:
<box id="group2">
	<menulist id="menu3">...</menulist>
	<menulist id="menu4">...</menulist>
</box>	
<box id="group1">
	<menulist id="menu1">...</menulist>
	<menulist id="menu2">...</menulist>
</box>
and my autotab moves the user correctly:  menu3, menu4, menu1, menu2
without having to dive back into the javascript.



More information about the Jslib mailing list