![]() |
|
|
#1
|
|||
|
|||
|
Start the cursor in the search box
I have a very basic php page that really just displays the standard menu items for the site plus a search box using a form and submit button. How do I get it so that the cursor is in the search box and the user can just start typing, rather than having to click in the box first?
Google does it if you can't understand what I am saying. |
|
#2
|
|||
|
|||
|
This is just a simple javascript code.
In <head> add this: <script> <!-- function focus(){document.FORM_NAME.INPUT_NAME.focus();} // --> </script> And then in <body>: <body onLoad=focus()> |
|
#3
|
|||
|
|||
|
Thanks, mate. Knew it wold be something simple.
|
|
#4
|
|||
|
|||
|
Browser compatibility
Does this work with Safari on a mac?
|
|
#5
|
|||
|
|||
|
Quote:
document.getElementById("input-id").focus(); input-id must be the value of the ID attribute of the input element, not name. J.D. |
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Download box pops up for results.php when I try to search | beckmann | All Other Tools | 4 | Feb 8th 2009 2:52 am |
| Google search quits on OS X.2 w/WebSTAR5.3 | mduke | All Other Tools | 7 | Nov 11th 2008 5:00 pm |
| Labs.google.com - New Tool Added just Hours AG0 | ! ! | 11 | Sep 26th 2004 3:44 pm | |
| New search start up funded by State of KS | anthonycea | All Other Search Engines | 3 | Jun 17th 2004 3:22 pm |
| Yet another "My search doesn't work on my site" (google/api related) | fugpup | All Other Tools | 4 | May 5th 2004 8:34 am |