Web Hosting Offers
See the new scripts recently added to Dynamic Drive. Click here.
Original, practical CSS codes and examples such as CSS menus for your site.
    Search code samples  
 
  Keyword
 
 
 
   
 
 
  Code Samples
 
ASP
CSS
Dhtml
Html
Javascript
PHP
 
   
     LOGIN HERE  
 
Username
Password
Forgot Password
Verify Signup
 
 
 

Javascript >> Forms >> General

How do I position the cursor on the first field of the first form when a page loads?

Visitor Ratings (3) :

Description
Using a named form and a named form field:

<body onLoad="document.myForm.myField.focus()">

<form name="myForm">
<input type="text" name="myField">
</form>

When the form and field names are not known then:

<body onLoad="document.forms[0].elements[0].focus()">

<form>
<input type="text">
</form>
Code
Select All
 Rate this Resource