Return to Snippet

Revision: 64558
at August 22, 2013 18:30 by apphp-snippets


Initial Code
<!-- This part goes into your body tag -->
<body OnLoad="document.myform.user.focus();">
 
<!-- You you just use the name of the form and field name within your form -->
<form name="myform">
Name:  <input type="text" name="user" size="10">
Email:  <input type="text" name="email" size="10">
</form>
 
</body>

Initial URL
http://www.apphp.com/index.php?snippet=javascript-focus-on-load

Initial Description
You can put the user's cursor inside a text box or put focus on select box as soon as your page is loaded. This helps ensure that visitors do not 'overlook' an important form item on your site and this snippet only uses one line of code!

Initial Title
Focus OnLoad in JavaScript

Initial Tags
javascript, load

Initial Language
JavaScript