onload = generically focus on first control

Discussion in 'Javascript' started by Fred, Aug 23, 2008.

  1. Fred

    Fred Guest

    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.
    Fred, Aug 23, 2008
    1. Advertisements

  2. Fred

    Kiran Makam Guest

    You can do this using the form object's elements collection:

    window.onload = function(){
    Kiran Makam, Aug 24, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.