Most search websites like Google have a convenient feature: After the page has been loaded, the cursor is already in the search field. This is quite easily done by the preceding code; the focus() method gives a form field the focus. A full listing is available in the file focus.html. Warning Note that the larger your page is and the more form fields it has, the more inconvenient this feature may get. Imagine a slowly loading page. While the page is loading, the user is probably already typing in another field. After the page has been fully loaded, the preceding code sets the focus to the designated field, eventually stealing the focus from the field the user is currently working on. |