Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cursor Position on Web Page first entry

    Hi,
    On my server home page there is a google search bar at top (On the page)
    And I was wondering how I make the cursor go on it automaticly when you go to it?
    For example - When you got to www.google.com you can just start typing because it's already in the box.

    Was wondering if anyone knew what the code was?

    Cheers

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    It's not always a good idea for overall usability to automatically focus a specific element within a page. Without seeing your page, it's impossible to say whether it's a good or bad idea in your case.
    If, like Google, the page is solely about the search field, then you're on safer (but not entirely safe) ground if you choose to auto-focus the search field. However, if the search field is only a minor component of the page, I wouldn't auto-focus it.



    Either way…

    js:
    Code:
    function focusSearch() {
    document.getElementById('searchfield').focus();
    }
    
    window.onload = focusSearch;
    markup:
    Code:
    <input type="text" id="searchfield" />
    Last edited by Bill Posters; 12-07-2005 at 12:02 PM.

  • #3
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yea
    Cheers dude exactly what I wanted yea its a google search bar at top of page.

    Thanks for your help

  • #4
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by antman
    its a google search bar at top of page.
    I got that bit. What I was saying is that if that's all there is on the page, then you're unlikely to harm the overall usability of the page by auto-focusing the search field. However, if it's just a search field on a page which has other (more important) content, then you may be doing more harm than good by automatically placing the focus on the search field.

    If the page contains real content, then it's unlikely that the search field will be the thing that most users arrived at a page to use. However, by setting the focus on the search field, you're ushering some users (such as those using screen-readers) straight past other elements of the page which they may actually wish to use. It can be a usability annoyance for them to have to navigate back to earlier elements (e.g. headings, menus, possibly content), but it's unlikely that users of GUI browsers are going to be annoyed by having to click within a search field if they want to use it.

    Something to consider.

  • #5
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yea its only for a network homepage on one of my servers
    Its weried it works on mine and another person but no one 2 other peoples lol.
    Could u see what i'v done wrong?
    www.redboxserver.org

    Im going to take it away when get my domain fowardings working (2mrw)

  • #6
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can't see anything immediately wrong. Do they have Javascript enabled? Perhaps you could try naming the text box without a space in it?

  • #7
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by mark87
    Can't see anything immediately wrong. Do they have Javascript enabled? Perhaps you could try naming the text box without a space in it?
    Indeed. In case it isn't now clear, identifiers (e.g. id, class and name attribute values) cannot have spaces in them).
    Jftr, they are also case-sensitive.
    Last edited by Bill Posters; 12-08-2005 at 09:14 AM.

  • #8
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Roger
    Was kind of thinking that when I was typing it hehe
    Thanks for your guys help


  •  

    Posting Permissions

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