
When I click onto an online form, I often see a blinking cursor appear automatically in the first field of the form. This is generally a good idea, because it saves me reaching for my mouse.
Automatic cursor placement can be accomplished with a single line of code. The prevailing implementation looks like this:
<body onload="document.forms['myForm'].elements['firstField'].focus()">
But there are some problems to watch out for. Is the automatic cursor placement expected and appropriate?Automatic cursor placement is often a good idea. It's great for simple web search (Google or Search.Yahoo.com) and it's fine for wizards (a.k.a. multi-page forms). When I'm creating a new form, my main concern is to do what's expected. Here are some questions that I ask.
And people wonder why the general public continue to type "www.ebay.com" into Google. Guess what - the search box is auto-selected! onLoad is too slowAnother technical "gotcha" is that the onLoad handler waits until all the images have loaded before firing. Over a slow connection, this can prevent the desired behavior. And in a login form, that minor bug can become a bit more serious. Login bug A better Automatic CursorFor the technical problem, there is a two pronged solution. (1) Make the cursor appear faster; and (2) don't mess with the cursor once the user has clicked anywhere on the form. To address the technical and usability issues, I've written this improved implementation of automatic cursor placement. ...But if that seems too complicated, then you can simply put the regular |
||||||||||||||
|
||||||||||||||