focus()

  • Thread starter James Lattanzio
  • Start date
J

James Lattanzio

Dear Anyone,

I have a form with many elements. I want the Submit button to have the
focus when the page is loaded, even though it is not first in the list of
elements to display. How can I do this?

Thank you.

James Lattanzio
 
J

Jukka K. Korpela

James Lattanzio said:
I have a form with many elements. I want the Submit button to
have the
focus when the page is loaded, even though it is not first in the
list of elements to display. How can I do this?

<input type="submit" id="subm">
<script type="text/javascript">
document.getElementById('subm').focus();
</script>
 
B

brucie

in post: <
James Lattanzio said:
I have a form with many elements. I want the Submit button to have the
focus when the page is loaded, even though it is not first in the list of
elements to display.

not a good idea. its really annoying when you're typing away and
suddenly the focus changes to another area.

don't expect your visitors to wait for the page to finish downloading
then for the cursor to move to where you want it before they start
filling out a form or for them to fill out the from in a top down
manner.
 
M

mscir

brucie said:
not a good idea. its really annoying when you're typing away and
suddenly the focus changes to another area.

don't expect your visitors to wait for the page to finish downloading
then for the cursor to move to where you want it before they start
filling out a form or for them to fill out the from in a top down
manner.

I agree, this happens to me on hotmail, it's really annoying.
 
J

Jukka K. Korpela

brucie said:
not a good idea. its really annoying when you're typing away and
suddenly the focus changes to another area.

While I generally agree with that principle, focusing on a submit button
_might_ be an exception. Consider a set of small pages, containing some
material divided into nice pieces, each with a link to the next piece.
And someone might use <form action="foo43.html"><input type="submit"
value="Next"></form> instead of a link. It might be convenient to the
user to just hit Enter to see the next piece. Of course it would be
better to replace the button with the real thing, a link, but even for a
real link, focusing on it could be nice _in rare special cases_.
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top