SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Internet Business Optimizer KCgame's Avatar
    Join Date
    Mar 2005
    Location
    Singapore
    Posts
    935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Body onload, textfield set focus not working in Firefox

    Hi all,

    I have the following code that set the focus of the username field upon page load:
    Code:
    <body onload="document.getElementById('mainuser').focus()">
    Its working fine in IE but not for FF..

    The page is at:
    http://www.absolutethree.com/

    Any help is appreciated.
    Thank you.

  2. #2
    d^_^b Iain G's Avatar
    Join Date
    Nov 2005
    Location
    Gloucester, UK
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This *shouldn't* work in IE either, but does because of a bug (surprise, surprise). getElementById should not work with the name attribute, but in IE it does. Set your code to <input class="inputu" id="mainuser" name="mainuser" size="15" type="text"> and it should work.

  3. #3
    Internet Business Optimizer KCgame's Avatar
    Join Date
    Mar 2005
    Location
    Singapore
    Posts
    935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Iain G
    This *shouldn't* work in IE either, but does because of a bug (surprise, surprise). getElementById should not work with the name attribute, but in IE it does. Set your code to <input class="inputu" id="mainuser" name="mainuser" size="15" type="text"> and it should work.
    Thanks
    Looks like my brain is trained to work better with the existence of bugs


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •