The problem is probably that you used frames, and the frame the field
is in does not have focus. Put the focus on the frame first using:
    window.focus();

I had the same problem and after I found this, the following code
works (in a JavaScript block):
    // set focus either on password or username field.
    document.loginForm.password.focus();
    if( document.loginForm.username.value == "" )
        document.loginForm.username.focus();
    window.focus();

I still have problems that the tab-key traversal jumps from the
forced focus field to the other frame first. After many tab-key
strikes, it finally traverses the username and password field to
the LOGIN button. This seems to be a netscape bug, in IE it works
correctly.

:) Christoph


"Foth, Oliver" wrote:
> 
> I've tried that, but as I said onLoad seems to be ignored. When I change
> onLoad to any other event-handler it works.
> 
> Here's my code:
> $page.addttribute("onLoad","document.forms.login.username")
> ..
> <form name="login">
> ..
> <input name="username">
> ..
> 
> -----Ursprungliche Nachricht-----
> Von: Simon Christian [mailto:[EMAIL PROTECTED]]
> Gesendet: Donnerstag, 21. Juni 2001 22:26
> An: [EMAIL PROTECTED]
> Betreff: Re: focus on an entry-field
> 
> There can't be a 'velocity-way' - the focus() functionality is purely
> client-side. It should work fine if you use something along these lines:
> 
> <body onLoad="document.forms.myForm.username.focus()">
> ..
> <form name="myForm">
> <input type="text" name="username">
> ..
> 
> - simon
> 
> "Foth, Oliver" wrote:
> >
> > Hi everybody,
> > I'd like to have a focus set on the username entry-field when th login.vm
> is
> > loaded. I tried to do that with javascript's event-handler onLoad, but it
> > doesn't work. The other event-handlers work fine. Is there a
> "velocity-way"
> > to set a focus? Why is onLoad ignored?
> >
> > Thanks in advance,
> >
> > Olli

Reply via email to