Focus OnLoad

You can put the user’s cursor inside a text box (calling the text box’ focus) as soon as the page is loaded. This helps ensure that visitors do not ‘overlook’ an important form item on your site. It only uses one line of code! This part goes into your body tag:

<BODY OnLoad="document.nameform.user.focus();">

Then you just use the name of the form and field name within your form (you can change the form and field names, but need to do so within the function and the form):

<form name="nameform">
Name:  <input type=text name=user size=10>

Leave a Reply