[thelist] Direct focus on login

Peter-Paul Koch pp.koch at gmail.com
Tue Nov 23 08:23:09 CST 2004


>The following code should work :
>window.onload=focusField;

Karen's solution is better. In this particular case onload is
deprecated and it's better to execute the script directly after the
form field has been written into the page.

Why?

Because the onload event may take too long to fire. Suppose you have a
page with lots of large images. The onload event doesn't fire until
each and every one of them has been loaded.

Now suppose the user doesn't wait for the images and starts to type
his login right away. When he's in the middle of his password all
images have been loaded, the onload event handler kicks in and puts
his focus back on the login field. That's not what the user wants, in
fact it's extremely annoying.

Therefore in this specific case it's better to execute the focus as
soon as possible: directly after the form fields have been written
into the page.

-- 
-------------------------------------------------------------------
ppk, freelance web developer
Interactie, copywriting, JavaScript, integratie
http://www.quirksmode.org/ 
------------------------------------------------------------------


More information about the thelist mailing list