[Javascript] onLoad Focus

Flavio Gomes flavio at economisa.com.br
Thu Apr 1 13:16:15 CST 2004


At the end of your page:

<script>
document.body.onLoad = document.form.inputField.focus();
</script>
  ----- Original Message ----- 
  From: John Cross 
  To: javascript at LaTech.edu 
  Sent: Thursday, April 01, 2004 3:51 PM
  Subject: [Javascript] onLoad Focus



  Hi All, 
  I am writing a web page where I build a list of submitted values, but as my list grows my input field gets pushed off the bottom of the visible page.  So I want to use the focus function to put the cursor in my input field when the page loads, so that by doing this the page will scroll to where my form is located.   So I've done this by using an onLoad function that focuses the cursor in my form field, but I'm gettign an error that my form field is not defined when the page loads.  This is caused, I believe, because my onLoad code is located in an include that gets loaded into the top of the page before the form (lower in the page) loads. 

  How can I make the page wait to focus the cursor until my form is loaded?  Thanks!!! 

  - John



------------------------------------------------------------------------------


  _______________________________________________
  Javascript mailing list
  Javascript at LaTech.edu
  https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20040401/a9806d5c/attachment.htm>


More information about the Javascript mailing list