cursor placement

D

DMc

When I open up my login page, I would like the cursor to be in the username
box. How would I achieve this?

Tia,
DMc.
 
M

Mark Parnell

DMc said:
When I open up my login page, I would like the cursor to be in the
username box. How would I achieve this?

It *can* be done with Javascript, but isn't recommended (for reasons that
others are probably better placed to explain than me ;-) ).
 
R

rf

Mark Parnell said:
It *can* be done with Javascript, but isn't recommended (for reasons that
others are probably better placed to explain than me ;-) ).

A quick user or one on a slow connection may, before the page finishes
loading, tab to the username box, fill it in and then proceed to the
password box and start typing. The page finishes loading at this point and
user doesn't notice that she is now typing in the username box again.
Frustrating.

Cheers
Richard.
 
A

andy johnson

When I open up my login page, I would like the cursor to be in the username
box. How would I achieve this?

Tia,
DMc.
I used "setting form focus" in Google and came up with this:

<html>
<body onload="document.myForm.field1.focus()">
<form name="myForm">
<input type="text" name="field1">
<Input type="text" name="field2">
</form>
</body>
</html>


-
Andy

"There would be a lot more civility in this world if people
didn't take that as an invitation to walk all over you"
- (Calvin and Hobbes)
 
T

Toby A Inkster

andy said:
I used "setting form focus" in Google and came up with this:

Why search on Google? Why not just look at Google's front page?

One thing to be aware of is that setting focus to a text field breaks the
user's keyboard shortcuts. They can't, for example, press the down button
to scroll down the page.
 
N

Nico Schuyt

DMc said:
When I open up my login page, I would like the cursor to be in the
username box. How would I achieve this?

<form method="POST" name="login" action="login_test.php">
<p><input type="text" name="password" size="7">
...............
</form>

<SCRIPT TYPE="text/javascript">
<!--
document.login.password.focus();
//-->
</SCRIPT>
 
A

andy johnson

Why search on Google? Why not just look at Google's front page?

One thing to be aware of is that setting focus to a text field breaks the
user's keyboard shortcuts. They can't, for example, press the down button
to scroll down the page.


You are right again. OTOH, I like the convenience of not having an
extra mouse move with this stinking eraser head mouse on this old
Thinkpad. If the form is a dreaded popup or a simple page the short
cuts probably shouldn't come into play.
-
Andy

"There would be a lot more civility in this world if people
didn't take that as an invitation to walk all over you"
- (Calvin and Hobbes)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top