onload moving cursor (focus) on first field of form

Discussion in 'Javascript' started by Zvonko, Aug 26, 2005.

  1. Zvonko

    Zvonko Guest

    Hi!

    As mentioned in title. How to do it?

    Thanks
    Zvonko
    Zvonko, Aug 26, 2005
    #1
    1. Advertising

  2. Zvonko

    Guest

    The easier version...

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

    Or the better version...

    <script language="javascript" type="text/javascript">
    function loadFocus() {
    document.forms[0].elements[0].focus();
    }
    window.onload = loadFocus;
    </script>

    Both will give the focus to the first field in the first form.

    Binny V A
    http://binnyva.blogspot.com
    , Aug 26, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason
    Replies:
    4
    Views:
    1,614
    Jason
    May 7, 2007
  2. dmaziuk
    Replies:
    3
    Views:
    568
    Chris Gonnerman
    Jan 25, 2011
  3. reneecccwest
    Replies:
    1
    Views:
    101
    McKirahan
    Feb 24, 2004
  4. Klaus Brune
    Replies:
    4
    Views:
    164
    Thiago Macedo
    May 29, 2008
  5. Fred
    Replies:
    1
    Views:
    88
    Kiran Makam
    Aug 24, 2008
Loading...

Share This Page