[thelist] Autofocus usability issues tackled

Matt Warden mwarden at gmail.com
Fri Oct 13 10:21:58 CDT 2006


On 10/13/06, Lee kowalkowski <lee.kowalkowski at googlemail.com> wrote:
> On 09/10/06, Christian Heilmann <codepo8 at gmail.com> wrote:
> > I have a pet peeve, which is web sites that automatically focus a
> > certain form field when the page has loaded. I understand the logic of
> > it, but more than once I found myself having already typed in half the
> > email - or, even worse, my password before being forcefully sent back
> > to the email field and delete what I entered there.
>
> This is the unfortunate thing about using event-driven design when
> it's not appropriate.  The onload event is not the right choice for
> setting form field focus, that is the problem, because of the issues
> you highlight.  Some documents can take ages to load, and a few never
> completely load (shame on them though).

Not always their fault :)

But you're right. This is why window.onload shouldn't be misused.

http://developer.yahoo.com/yui/docs/event/YAHOO.util.Event.html#onAvailable

> My preferred solution is to include a script element immediately (or
> as soon as possible) after the field that requires focus:
>
> <script src="focus.js" type="text/javascript"></script>
>
> User agents must execute this script immediately, because it may
> containt things like document.write which must be executed before the
> document is parsed.

But then you've got script tags all over your document, just for
execution order purposes? Take a look at onAvailable (link above).
Most other (good) libraries have something similar, too.

-- 
Matt Warden
Cleveland, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the thelist mailing list