Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > onload = generically focus on first control

Reply
Thread Tools

onload = generically focus on first control

 
 
Fred
Guest
Posts: n/a
 
      08-23-2008
Hi. Can I make the first control (textfield or text area) get focus via
onload, without referring to the object's name of id? Thanks.
 
Reply With Quote
 
 
 
 
Kiran Makam
Guest
Posts: n/a
 
      08-24-2008
You can do this using the form object's elements collection:

window.onload = function(){
document.yourFormName.elements[0].focus();
}


On Aug 23, 8:21*pm, Fred <(E-Mail Removed)> wrote:
> Hi. Can I make the first control (textfield or text area) get focus via
> onload, without referring to the object's name of id? Thanks.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
emulating window.focus in Body onload() event and setting focus to a control on same page Jason ASP .Net 4 05-07-2007 05:54 PM
this.window.focus() vs. window.focus() vs. this.focus() Roger Javascript 3 03-08-2007 08:53 PM
onload moving cursor (focus) on first field of form Zvonko Javascript 1 08-26-2005 11:40 AM
focus on first text form field w/o using onload reneecccwest Javascript 1 02-24-2004 10:03 PM
generically controlling precision of date display SN Java 4 11-13-2003 05:26 AM



Advertisments