Subj : Re: Controlling tab order with JavaScript To : netscape.public.mozilla.jseng,comp.lang.javascript From : Mark Reginald James Date : Sat Sep 24 2005 08:26 pm Randy Webb wrote: > Mark Reginald James said the following on 9/24/2005 2:28 PM: > >> Hi, >> >> I'm trying to use a keyboard event function to change what >> element gets the focus after tab is pressed in a particular >> element. Simple HTML that demonstrates the problem is below. > > > Your problem is that you are trying to redefine the way the browser > works. That is going to confuse users because they expect the default > behavior and you are screwing with it. > > If you want to change the tab order, set the tabindex. > > > > Problem solved. Thanks Randy, but I don't think I can do that easily, if at all. What I'm really doing is inserting a new text box when focus is lost on the bottom text box of a set and the contents of the box is non-blank. If focus is lost by clicking on another element, then move the focus there. But if tab is pressed, focus should move to the new box. It would be quite complicated to dynamically set the tabindices, and I'm not even sure whether browers will immediately take into account the tabindex of the newly-created box. The code I gave works, it's just browser-dependent. I don't know why onkeydown and onkeypress have different tab-related behaviour in Mozilla. .