 |
 |
making courser jump to text field on page load
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2003
Status:
Offline
|
|
I am making a page with text box fields, and I would like to have courser jump to the first text box when the page loads. I searched for a javascript, but I didn't find one.
Does anyone know how to do this?
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
Code:
document.getElementById("inputsID").focus()
should do the trick. I'm not sure if it's setFocus() for MSIE...
There's other ways of referencing the element (text box) too, like
Code:
document.getElementsByTagName("input")[0].focus()
so it's up to you...
|
|
Just who are Britain? What do they? Who is them? And why?
Formerly Black Book
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Dec 2002
Status:
Offline
|
|
I hate sites that do that, because I can usually type what I need in the first field before the page even loads completely (even though I'm on a 1.5Mbps connection) and I start typing the next field, the javascript selects the first field, and I lose what I typed! So annoying, don't do it!
|
|
Travis Sanderson
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Sep 2000
Location: New Jersey, USA
Status:
Offline
|
|
I understood it as the actual mouse cursor jumping to the text field. Physical location of pointer on the display. The other posts seem to describe the selected text field. I do not know how to attempt the cursor itself but just thought I'd mention it.
Otherwise the original question seemed to miscommunicate the actual intent.
|
Dual 2.0 G5/2.5GB/ATI 9800 Pro | MacBook Pro 2.16 Gore Duo/2GB/ATI X1600
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Oct 2003
Status:
Offline
|
|
I have seen a few pages do this without javascript. It is weird, but if there is an input box positioned correctly, alot of browsers seem to automatically select it. I'm not sure exactly what is happening on those pages, but I've come across a few pages in the past that did this, and when I checked source, there was no javascript or anything else I could find that would be making this happen. And almost all browsers I tried it in did it. Weird.
But if you want to do it and make sure it works, use javascript. some people may find it annoying for like a "form" with many inputs, as already mentioned. I think it's best use would be on the search input box on a page, especially if you found people often used the "quick search" box or whatever, if you have one.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
I originally assumed he meant moving the mouse pointer, but since it can't be done, decided to answer the question as if he wanted to just focus on a text box.
I think you can use 'tabindex' to set which input is highlighted first - not sure though...
|
|
Just who are Britain? What do they? Who is them? And why?
Formerly Black Book
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|